mirror of
				https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
				synced 2025-11-04 06:11:46 +00:00 
			
		
		
		
	rework getters, setters in higher classes
This commit is contained in:
		
							parent
							
								
									bee52b6541
								
							
						
					
					
						commit
						4e9ff66640
					
				@ -75,7 +75,7 @@ class RemoteBasic : Remote {
 | 
			
		||||
        $this.bus = Make_Buses($this)
 | 
			
		||||
        $this.button = Make_Buttons
 | 
			
		||||
        $this.vban = Make_Vban($this)
 | 
			
		||||
        $this.command = Make_Command
 | 
			
		||||
        $this.command = Make_Command($this)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -92,7 +92,7 @@ class RemoteBanana : Remote {
 | 
			
		||||
        $this.bus = Make_Buses($this)
 | 
			
		||||
        $this.button = Make_Buttons
 | 
			
		||||
        $this.vban = Make_Vban($this)
 | 
			
		||||
        $this.command = Make_Command
 | 
			
		||||
        $this.command = Make_Command($this)
 | 
			
		||||
        $this.recorder = Make_Recorder($this)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -110,7 +110,7 @@ class RemotePotato : Remote {
 | 
			
		||||
        $this.bus = Make_Buses($this)
 | 
			
		||||
        $this.button = Make_Buttons
 | 
			
		||||
        $this.vban = Make_Vban($this)
 | 
			
		||||
        $this.command = Make_Command
 | 
			
		||||
        $this.command = Make_Command($this)
 | 
			
		||||
        $this.recorder = Make_Recorder($this)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -18,15 +18,15 @@ class IBus {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [single] Getter ($param) {
 | 
			
		||||
        return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false
 | 
			
		||||
        return $this.remote.Getter("$($this.identifier()).$param")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [string] Getter_String ($param) {
 | 
			
		||||
        return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $true
 | 
			
		||||
        return $this.remote.Getter_String("$($this.identifier()).$param")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [void] Setter ($param, $set) {
 | 
			
		||||
        Param_Set -PARAM "$($this.identifier()).$param" -Value $set
 | 
			
		||||
    [void] Setter ($param, $val) {
 | 
			
		||||
        $this.remote.Setter("$($this.identifier()).$param", $val)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,12 @@
 | 
			
		||||
. $PSScriptRoot\inst.ps1
 | 
			
		||||
 | 
			
		||||
class Special {
 | 
			
		||||
    Special () {
 | 
			
		||||
    [Object]$remote
 | 
			
		||||
 | 
			
		||||
    Special ([Object]$remote) {
 | 
			
		||||
        AddActionMembers -PARAMS @('restart', 'shutdown', 'show')
 | 
			
		||||
    
 | 
			
		||||
        $this.remote = $remote
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [string] identifier () {
 | 
			
		||||
@ -15,15 +19,15 @@ class Special {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [single] Getter ($param) {
 | 
			
		||||
        return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false
 | 
			
		||||
        return $this.remote.Getter("$($this.identifier()).$param")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [void] Setter ($param, $val) {
 | 
			
		||||
        if ($val -is [Boolean]) {
 | 
			
		||||
            Param_Set -PARAM "$($this.identifier()).$param" -Value $(if ($val) { 1 } else { 0 })
 | 
			
		||||
            $this.remote.Setter("$($this.identifier()).$param", $(if ($val) { 1 } else { 0 }))
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            Param_Set -PARAM "$($this.identifier()).$param" -Value $val
 | 
			
		||||
            $this.remote.Setter("$($this.identifier()).$param", $val)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -67,6 +71,6 @@ class Special {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function Make_Command {
 | 
			
		||||
    return [Special]::new()
 | 
			
		||||
function Make_Command([Object]$remote) {
 | 
			
		||||
    return [Special]::new($remote)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -8,15 +8,15 @@ class IRecorder {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [single] Getter ($param) {
 | 
			
		||||
        return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false
 | 
			
		||||
        return $this.remote.Getter("$($this.identifier()).$param")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [void] Setter ($param, $val) {
 | 
			
		||||
        if ($val -is [Boolean]) {
 | 
			
		||||
            Param_Set -PARAM "$($this.identifier()).$param" -Value $(if ($val) { 1 } else { 0 })
 | 
			
		||||
            $this.remote.Setter("$($this.identifier()).$param", $(if ($val) { 1 } else { 0 }))
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            Param_Set -PARAM "$($this.identifier()).$param" -Value $val
 | 
			
		||||
            $this.remote.Setter("$($this.identifier()).$param", $val)
 | 
			
		||||
        }
 | 
			
		||||
    }    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -14,15 +14,15 @@ class IStrip {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [single] Getter ($param) {
 | 
			
		||||
        return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false
 | 
			
		||||
        return $this.remote.Getter("$($this.identifier()).$param")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [string] Getter_String ($param) {
 | 
			
		||||
        return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $true
 | 
			
		||||
        return $this.remote.Getter_String("$($this.identifier()).$param")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [void] Setter ($param, $val) {
 | 
			
		||||
        Param_Set -PARAM "$($this.identifier()).$param" -Value $val
 | 
			
		||||
        $this.remote.Setter("$($this.identifier()).$param", $val)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										20
									
								
								lib/vban.ps1
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								lib/vban.ps1
									
									
									
									
									
								
							@ -1,9 +1,11 @@
 | 
			
		||||
class IVban {
 | 
			
		||||
    [int32]$index
 | 
			
		||||
    [Object]$remote
 | 
			
		||||
    [string]$direction
 | 
			
		||||
 | 
			
		||||
    IVban ([int]$index, [string]$direction) {
 | 
			
		||||
    IVban ([int]$index, [Object]$remote, [string]$direction) {
 | 
			
		||||
        $this.index = $index
 | 
			
		||||
        $this.remote = $remote
 | 
			
		||||
        $this.direction = $direction
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -16,20 +18,20 @@ class IVban {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [single] Getter ($param) {
 | 
			
		||||
        return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false
 | 
			
		||||
        return $this.remote.Getter("$($this.identifier()).$param")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [string] Getter_String ($param) {
 | 
			
		||||
        return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $true
 | 
			
		||||
        return $this.remote.Getter_String("$($this.identifier()).$param")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [void] Setter ($param, $val) {
 | 
			
		||||
        Param_Set -PARAM "$($this.identifier()).$param" -Value $val
 | 
			
		||||
        $this.remote.Setter("$($this.identifier()).$param", $val)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class Vban : IVban {
 | 
			
		||||
    Vban ([int]$index, [string]$direction) : base ($index, $direction) {
 | 
			
		||||
    Vban ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    hidden $_on = $($this | Add-Member ScriptProperty 'on' `
 | 
			
		||||
@ -173,13 +175,13 @@ class Vban : IVban {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class VbanInstream : Vban {
 | 
			
		||||
    VbanInstream ([int]$index, [string]$direction) : base ($index, $direction) {
 | 
			
		||||
    VbanInstream ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class VbanOutstream : Vban {
 | 
			
		||||
    VbanOutstream ([int]$index, [string]$direction) : base ($index, $direction) {
 | 
			
		||||
    VbanOutstream ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -189,10 +191,10 @@ function Make_Vban ([Object]$remote) {
 | 
			
		||||
    [System.Collections.ArrayList]$outstream = @()
 | 
			
		||||
 | 
			
		||||
    0..$($remote.kind.vban_in - 1) | ForEach-Object {
 | 
			
		||||
        [void]$instream.Add([VbanInstream]::new($_, "in"))
 | 
			
		||||
        [void]$instream.Add([VbanInstream]::new($_, $remote, "in"))
 | 
			
		||||
    }
 | 
			
		||||
    0..$($remote.kind.vban_out - 1) | ForEach-Object {
 | 
			
		||||
        [void]$outstream.Add([VbanOutstream]::new($_, "out"))
 | 
			
		||||
        [void]$outstream.Add([VbanOutstream]::new($_, $remote, "out"))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $CustomObject = [pscustomobject]@{
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user