Public/New-OpmlOutline.ps1
function New-OpmlOutline { param ( [Parameter(Mandatory, Position = 0)][string]$Text, [string]$Type, [hashtable]$Attribute, [Parameter(ValueFromPipeline)][Outline[]]$Outline ) begin { $CachedItems = New-Object -TypeName System.Collections.Generic.List[Outline] } process { if ($Outline) { $CachedItems.AddRange($Outline) } } end { $Result = [Outline]::new($Text) if ($Type) { $Result.Type = $Type } if ($Attribute) { $Attribute.Keys | ForEach-Object { $Result.Attributes.Add($_, $Attribute[$_]) } } if ($CachedItems) { $Result.ChildNodes.AddRange($CachedItems) } $Result } } |