Skip to content

Commit f059900

Browse files
StartAutomatingStartAutomating
authored andcommitted
ParameterAst: Adding .Binding and .DefaultBindingProperty (re #305)
1 parent 07b7a53 commit f059900

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

PipeScript.types.ps1xml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,42 @@ $this.Parent.Extent.ToString().Substring(0, $offsetDifference) -replace '^[\r\n\
932932
<Name>VFPBN</Name>
933933
<ReferencedMemberName>ByPropertyName</ReferencedMemberName>
934934
</AliasProperty>
935+
<ScriptProperty>
936+
<Name>Binding</Name>
937+
<GetScriptBlock>
938+
$isBindable = $false
939+
foreach ($attr in $this.Attributes) {
940+
$reflectedType = $attr.TypeName.GetReflectionType()
941+
if ((-not $reflectedType) -or
942+
$reflectedType -notin [ComponentModel.DefaultBindingPropertyAttribute],
943+
[ComponentModel.BindableAttribute],
944+
[ComponentModel.ComplexBindingPropertiesAttribute]) {
945+
continue
946+
}
947+
948+
$positionalArguments = @(
949+
foreach ($positionalParameter in $attr.PositionalArguments) {
950+
$positionalParameter.Value
951+
}
952+
)
953+
$realAttribute =
954+
if ($positionalArguments) {
955+
$reflectedType::new($positionalArguments)
956+
} else {
957+
$reflectedType::new()
958+
}
959+
960+
961+
foreach ($namedArgument in $attr.NamedArguments) {
962+
if ($namedArgument.ArgumentName -eq 'Name') {
963+
$realAttribute.$($namedArgument.ArgumentName) = $namedArgument.Argument.Value
964+
}
965+
}
966+
$realAttribute
967+
}
968+
969+
</GetScriptBlock>
970+
</ScriptProperty>
935971
<ScriptProperty>
936972
<Name>ByPropertyName</Name>
937973
<GetScriptBlock>
@@ -955,6 +991,42 @@ $this.Parent.Extent.ToString().Substring(0, $offsetDifference) -replace '^[\r\n\
955991
return $false
956992
</GetScriptBlock>
957993
</ScriptProperty>
994+
<ScriptProperty>
995+
<Name>DefaultBindingProperty</Name>
996+
<GetScriptBlock>
997+
$isBindable = $false
998+
foreach ($attr in $this.Attributes) {
999+
$reflectedType = $attr.TypeName.GetReflectionType()
1000+
if ($reflectedType -ne [ComponentModel.DefaultBindingPropertyAttribute]) {
1001+
if ($reflectedType -eq [ComponentModel.BindableAttribute]) {
1002+
if ($attr.PositionalArguments.Value -eq $false) {
1003+
return ''
1004+
} else {
1005+
$isBindable = $true
1006+
}
1007+
}
1008+
continue
1009+
}
1010+
1011+
foreach ($positionalParameter in $attr.PositionalArguments) {
1012+
return $positionalParameter.Value
1013+
}
1014+
1015+
foreach ($namedArgument in $attr.NamedArguments) {
1016+
if ($namedArgument.ArgumentName -eq 'Name') {
1017+
return $namedArgument.Argument.Value
1018+
}
1019+
}
1020+
}
1021+
1022+
1023+
if ($isBindable) {
1024+
return $this.Name.VariablePath.ToString()
1025+
} else {
1026+
return ''
1027+
}
1028+
</GetScriptBlock>
1029+
</ScriptProperty>
9581030
<ScriptProperty>
9591031
<Name>DisplayName</Name>
9601032
<GetScriptBlock>

0 commit comments

Comments
 (0)