Files
Resolve-DSCConfigurationData/Private/Split-ConfigurationDataExpressionArguments.ps1
Torsten Brendgen 4b83abc7f2 initial Commit
2026-06-27 00:36:04 +02:00

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
}