mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-01-18 05:10:48 +00:00
Create meta.ps1
meta functions for different property types moved into meta.ps1
This commit is contained in:
parent
a7913f8934
commit
2527399da0
52
lib/meta.ps1
Normal file
52
lib/meta.ps1
Normal file
@ -0,0 +1,52 @@
|
||||
Function AddPublicMembers($this) {
|
||||
[HashTable]$Signatures = @{}
|
||||
ForEach($param in $this.bool_params) {
|
||||
# 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
|
||||
}
|
||||
|
||||
ForEach($param in $this.float_params) {
|
||||
# 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
|
||||
}
|
||||
|
||||
ForEach($param in $this.int_params) {
|
||||
# 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
|
||||
}
|
||||
|
||||
ForEach($param in $this.string_params) {
|
||||
# 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"])
|
||||
}
|
||||
$this | Add-Member @AddMemberParams
|
||||
}
|
Loading…
Reference in New Issue
Block a user