2022-01-08 20:30:36 +00:00
|
|
|
Function AddPublicMembers($obj) {
|
2022-01-06 15:26:01 +00:00
|
|
|
[HashTable]$Signatures = @{}
|
2022-01-08 20:30:36 +00:00
|
|
|
ForEach($param in $obj.bool_params) {
|
2022-01-06 15:26:01 +00:00
|
|
|
# Define getter
|
|
|
|
$Signatures["Getter"] = "`$this.Getter(`$this.cmd('{0}'))" -f $param
|
|
|
|
# Define setter
|
|
|
|
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
|
|
|
|
-f $param
|
|
|
|
|
|
|
|
Addmember
|
|
|
|
}
|
|
|
|
|
2022-01-08 20:30:36 +00:00
|
|
|
ForEach($param in $obj.float_params) {
|
2022-01-06 15:26:01 +00:00
|
|
|
# Define getter
|
|
|
|
$Signatures["Getter"] = "[math]::Round(`$this.Getter(`$this.cmd('{0}')), 1)" -f $param
|
|
|
|
# Define setter
|
|
|
|
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
|
|
|
|
-f $param
|
|
|
|
|
|
|
|
Addmember
|
|
|
|
}
|
|
|
|
|
2022-01-08 20:30:36 +00:00
|
|
|
ForEach($param in $obj.int_params) {
|
2022-01-06 15:26:01 +00:00
|
|
|
# Define getter
|
|
|
|
$Signatures["Getter"] = "[Int]`$this.Getter(`$this.cmd('{0}'))" -f $param
|
|
|
|
# Define setter
|
|
|
|
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
|
|
|
|
-f $param
|
|
|
|
|
|
|
|
Addmember
|
|
|
|
}
|
|
|
|
|
2022-01-08 20:30:36 +00:00
|
|
|
ForEach($param in $obj.string_params) {
|
2022-01-06 15:26:01 +00:00
|
|
|
# Define getter
|
|
|
|
$Signatures["Getter"] = "[String]`$this.Getter_String(`$this.cmd('{0}'))" -f $param
|
|
|
|
# Define setter
|
|
|
|
$Signatures["Setter"] = "param ( [String]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
|
|
|
|
-f $param
|
|
|
|
|
|
|
|
Addmember
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Function Addmember{
|
|
|
|
$AddMemberParams = @{
|
|
|
|
Name = $param
|
|
|
|
MemberType = 'ScriptProperty'
|
|
|
|
Value = [ScriptBlock]::Create($Signatures["Getter"])
|
|
|
|
SecondValue = [ScriptBlock]::Create($Signatures["Setter"])
|
|
|
|
}
|
2022-01-08 20:30:36 +00:00
|
|
|
$obj | Add-Member @AddMemberParams
|
2022-01-06 15:26:01 +00:00
|
|
|
}
|