Skip to content

Commit d92695b

Browse files
author
James Brundage
committed
Adding VBN (#48)
1 parent f7cddce commit d92695b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

Transpilers/Parameters/VBN.psx.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<#
2+
.SYNOPSIS
3+
ValueFromPipline Shorthand
4+
.DESCRIPTION
5+
This is syntax shorthand to create [Parameter] attributes that take ValueFromPipelineByPropertyName.
6+
#>
7+
[Alias('VFPBPN')]
8+
param(
9+
[Alias('ParameterSetName')]
10+
[string]
11+
$ParameterSet,
12+
13+
[switch]
14+
$Mandatory,
15+
16+
[Alias('VFP')]
17+
[switch]
18+
$ValueFromPipeline
19+
)
20+
21+
$paramOptions = @(
22+
if ($Mandatory) {
23+
"Mandatory"
24+
}
25+
if ($ParameterSet) {
26+
"ParameterSetName='$($ParameterSet.Replace("'","''"))'"
27+
}
28+
"ValueFromPipelineByPropertyName"
29+
if ($ValueFromPipeline) {
30+
"ValueFromPipeline"
31+
}
32+
if ($PSBoundParameters.ContainsKey('Position')) {
33+
"Position=$position"
34+
}
35+
) -join ','
36+
37+
$nsb = [ScriptBlock]::Create(
38+
"[Parameter($paramOptions)]param()"
39+
)
40+
41+
$nsb

0 commit comments

Comments
 (0)