initial Commit
This commit is contained in:
38
Private/Invoke-ConfigurationDataExpression.ps1
Normal file
38
Private/Invoke-ConfigurationDataExpression.ps1
Normal file
@@ -0,0 +1,38 @@
|
||||
function Invoke-ConfigurationDataExpression {
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$Expression,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
$Context
|
||||
)
|
||||
|
||||
$Expression = $Expression.Trim()
|
||||
|
||||
if($Expression -match "^'(.*)'$"){
|
||||
return $Matches[1]
|
||||
}
|
||||
|
||||
if($Expression -match "^-?\d+$"){
|
||||
return [int]$Expression
|
||||
}
|
||||
|
||||
if($Expression -match "^(?i:true|false)$"){
|
||||
return [bool]::Parse($Expression)
|
||||
}
|
||||
|
||||
if($Expression -notmatch "^([A-Za-z][A-Za-z0-9]*)\((.*)\)$"){
|
||||
throw "Invalid configuration data expression [$Expression]."
|
||||
}
|
||||
|
||||
$FunctionName = $Matches[1]
|
||||
$ArgumentText = $Matches[2]
|
||||
$Arguments = @()
|
||||
foreach($Argument in @(Split-ConfigurationDataExpressionArguments -ArgumentText $ArgumentText)){
|
||||
$Arguments += ,(Invoke-ConfigurationDataExpressionArgument -Argument $Argument -Context $Context)
|
||||
}
|
||||
|
||||
return Invoke-ConfigurationDataExpressionFunction -Name $FunctionName -Arguments $Arguments -Context $Context
|
||||
}
|
||||
Reference in New Issue
Block a user