Pax8API/Private/ConvertTo-Pax8WireValue.ps1
|
function ConvertTo-Pax8WireValue { [CmdletBinding()] param ( [Parameter(ValueFromPipeline)] [object]$Value ) process { if ($null -eq $Value) { return $null } if ($Value -is [guid]) { return $Value.Guid } if ($Value -is [datetime]) { return $Value.ToString('o') } if ($Value -is [System.Collections.IDictionary]) { $converted = [ordered]@{} foreach ($key in $Value.Keys) { $converted[$key] = ConvertTo-Pax8WireValue -Value $Value[$key] } return $converted } if ($Value -is [System.Collections.IEnumerable] -and $Value -isnot [string]) { $items = @() foreach ($item in $Value) { $items += ConvertTo-Pax8WireValue -Value $item } return $items } $Value } } |