mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-12-05 05:07:47 +00:00
52 lines
1.4 KiB
PowerShell
52 lines
1.4 KiB
PowerShell
class IRemote {
|
|
[Nullable[int]]$index
|
|
[Object]$remote
|
|
|
|
IRemote ([Object]$remote) {
|
|
$this.remote = $remote
|
|
}
|
|
|
|
IRemote ([int]$index, [Object]$remote) {
|
|
$this.index = $index
|
|
$this.remote = $remote
|
|
}
|
|
|
|
[single] Getter ($param) {
|
|
$this.ToString() + " Getter: $($this.Cmd($param))" | Write-Debug
|
|
return $this.remote.Getter($this.Cmd($param))
|
|
}
|
|
|
|
[string] Getter_String ($param) {
|
|
$this.ToString() + " Getter_String: $($this.Cmd($param))" | Write-Debug
|
|
return $this.remote.Getter_String($this.Cmd($param))
|
|
}
|
|
|
|
[void] Setter ($param, $val) {
|
|
$this.ToString() + " Setter: $($this.Cmd($param))=$val" | Write-Debug
|
|
if ($val -is [Boolean]) {
|
|
$this.remote.Setter($this.Cmd($param), $(if ($val) { 1 } else { 0 }))
|
|
}
|
|
else {
|
|
$this.remote.Setter($this.Cmd($param), $val)
|
|
}
|
|
}
|
|
|
|
[string] Cmd ($param) {
|
|
if ([string]::IsNullOrEmpty($param)) {
|
|
return $this.identifier()
|
|
}
|
|
return "$($this.identifier()).$param"
|
|
}
|
|
|
|
# Must be overridden by derived classes
|
|
[string] identifier () {
|
|
throw [System.NotImplementedException]::new("$($this.GetType().Name) must override identifier()")
|
|
}
|
|
|
|
[string] ToString() {
|
|
if ($null -ne $this.index) {
|
|
return $this.GetType().Name + $this.index
|
|
}
|
|
return $this.GetType().Name
|
|
}
|
|
} |