initial Commit
This commit is contained in:
47
Private/Split-ConfigurationDataExpressionArguments.ps1
Normal file
47
Private/Split-ConfigurationDataExpressionArguments.ps1
Normal file
@@ -0,0 +1,47 @@
|
||||
function Split-ConfigurationDataExpressionArguments {
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[AllowNull()]
|
||||
[string]
|
||||
$ArgumentText
|
||||
)
|
||||
|
||||
if([string]::IsNullOrWhiteSpace($ArgumentText)){
|
||||
return @()
|
||||
}
|
||||
|
||||
$Arguments = @()
|
||||
$Current = New-Object -TypeName System.Text.StringBuilder
|
||||
$Depth = 0
|
||||
$InString = $false
|
||||
|
||||
for($Index = 0; $Index -lt $ArgumentText.Length; $Index++){
|
||||
$Character = $ArgumentText[$Index]
|
||||
|
||||
if($Character -eq "'"){
|
||||
[void]$Current.Append($Character)
|
||||
$InString = -not $InString
|
||||
continue
|
||||
}
|
||||
|
||||
if(-not $InString){
|
||||
if($Character -eq "("){
|
||||
$Depth++
|
||||
}elseif($Character -eq ")"){
|
||||
$Depth--
|
||||
}elseif($Character -eq "," -and $Depth -eq 0){
|
||||
$Arguments += $Current.ToString().Trim()
|
||||
[void]$Current.Clear()
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
[void]$Current.Append($Character)
|
||||
}
|
||||
|
||||
if($Current.Length -gt 0){
|
||||
$Arguments += $Current.ToString().Trim()
|
||||
}
|
||||
|
||||
return $Arguments
|
||||
}
|
||||
Reference in New Issue
Block a user