48 lines
1.1 KiB
PowerShell
48 lines
1.1 KiB
PowerShell
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
|
|
}
|