-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Akaizoku/develop
Improvements
- Loading branch information
Showing
5 changed files
with
190 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
function ConvertTo-JavaProperty { | ||
<# | ||
.SYNOPSIS | ||
Convert to Java property | ||
.DESCRIPTION | ||
Format property key-value pair as Java property | ||
.PARAMETER Property | ||
The property parameter corresponds to the property key-value pair to format. | ||
.PARAMETER Prefix | ||
The optional prefix parameter corresponds to the prefix of the expected Java property. The default value is "D". | ||
.INPUTS | ||
System.Collections.Specialized.OrderedDictionary. You can pipe the property key-value pair to ConvertTo-JavaProperty. | ||
.OUTPUTS | ||
System.String. ConvertTo-JavaProperty returns the formatted Java property. | ||
.NOTES | ||
File name: ConvertTo-JavaProperty.ps1 | ||
Author: Florian Carrier | ||
Creation date: 15/10/2019 | ||
Last modified: 16/01/2020 | ||
#> | ||
[CmdletBinding ()] | ||
Param( | ||
[Parameter ( | ||
Position = 1, | ||
Mandatory = $true, | ||
HelpMessage = "Property key-value pair", | ||
ValueFromPipeline = $true | ||
)] | ||
[ValidateNotNullOrEmpty()] | ||
[Alias ("Properties")] | ||
[System.Collections.Specialized.OrderedDictionary] | ||
$Property, | ||
[Parameter ( | ||
Position = 2, | ||
Mandatory = $false, | ||
HelpMessage = "Java property prefix" | ||
)] | ||
[String] | ||
$Prefix = "D" | ||
) | ||
Begin { | ||
# Get global preference variables | ||
Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState | ||
} | ||
Process { | ||
if ($Property.Count -gt 0) { | ||
$JavaString = New-Object -TypeName "System.String" -ArgumentList "" | ||
# Loop through properties (if multiple have been provided) | ||
foreach ($SingleProperty in $Property.GetEnumerator()) { | ||
# Add space between consecutive properties | ||
if ($JavaString) { | ||
$JavaString += " " | ||
} | ||
# Format property | ||
$JavaString += "-" + $Prefix + '"' + $SingleProperty.Name + '"' + "=" + '"' + $SingleProperty.Value + '"' | ||
} | ||
# Return Java property string | ||
return $JavaString | ||
} else { | ||
# If property is invalid | ||
return $null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters