Skip to content

Commit 02de798

Browse files
author
James Brundage
committed
Documenting Decorate Transpiler (Fixes #222)
1 parent 2653057 commit 02de798

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Transpilers/Decorate.psx.ps1

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
[Alias('PSTypeName', 'Management.Automation.PSTypeName', 'System.Management.Automation.PSTypeName')]
2-
[CmdletBinding(DefaultParameterSetName='ScriptBlock')]
1+
<#
2+
.SYNOPSIS
3+
decorate transpiler
4+
.DESCRIPTION
5+
Applies one or more typenames to an object.
6+
By 'decorating' the object with a typename, this enables use of the extended type system.
7+
.EXAMPLE
8+
{
9+
$v = [PSCustomObject]@{}
10+
[decorate('MyTypeName',Clear,PassThru)]$v
11+
}.Transpile()
12+
#>
13+
[Alias('PSTypeName', 'Management.Automation.PSTypeName', 'System.Management.Automation.PSTypeName')]
314
param(
415
# The variable decoration will be applied to.
5-
[Parameter(Mandatory=$true,ParameterSetName='VariableAST', ValueFromPipeline)]
16+
[Parameter(Mandatory,ParameterSetName='VariableAST', ValueFromPipeline)]
617
[Management.Automation.Language.VariableExpressionast]
718
$VariableAst,
819

@@ -31,7 +42,7 @@ process {
3142
if ($clear) {
3243
$variableText + ".pstypenames.clear()"
3344
}
34-
foreach ($tn in $PSTypeName) {
45+
foreach ($tn in $TypeName) {
3546
$stn = $tn.Replace("'","''")
3647
$variableText + ".pstypenames.add('$stn')"
3748
}

0 commit comments

Comments
 (0)