2021-08-23 15:24:05 +01:00
|
|
|
class Special {
|
|
|
|
hidden AddPublicMembers($commands) {
|
|
|
|
$commands | ForEach-Object {
|
|
|
|
# Define getter
|
2022-01-06 15:27:48 +00:00
|
|
|
$GetterSignature = "`$this.Getter(`$this.cmd('{0}'))" -f $_
|
2021-08-23 15:24:05 +01:00
|
|
|
# Define setter
|
|
|
|
$SetterSignature = "`$this.Setter(`$this.cmd('{0}'))" -f $_
|
|
|
|
|
|
|
|
$AddMemberParams = @{
|
|
|
|
Name = $_
|
|
|
|
MemberType = 'ScriptProperty'
|
|
|
|
Value = [ScriptBlock]::Create($SetterSignature)
|
2022-01-06 15:27:48 +00:00
|
|
|
SecondValue = [ScriptBlock]::Create($GetterSignature)
|
2021-08-23 15:24:05 +01:00
|
|
|
}
|
|
|
|
$this | Add-Member @AddMemberParams
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Constructor
|
|
|
|
Special()
|
|
|
|
{
|
|
|
|
$this.AddPublicMembers(@('restart', 'shutdown', 'show'))
|
|
|
|
}
|
|
|
|
|
|
|
|
[String] Getter($param) {
|
2022-01-09 14:24:09 +00:00
|
|
|
return Write-Warning("ERROR: Usage: $param")
|
2021-08-23 15:24:05 +01:00
|
|
|
}
|
|
|
|
|
2022-01-09 14:24:09 +00:00
|
|
|
[void] Setter($param, $val = $true) {
|
|
|
|
Param_Set -PARAM $param -VALUE $(if ($val) {1} else {0})
|
2021-08-23 15:24:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
[String] cmd ($arg) {
|
|
|
|
return "Command.$arg"
|
|
|
|
}
|
|
|
|
|
|
|
|
hidden $_showvbanchat = $($this | Add-Member ScriptProperty 'showvbanchat' `
|
|
|
|
{
|
2022-01-09 14:24:09 +00:00
|
|
|
$this.Getter($this.cmd('DialogShow.VBANCHAT'))
|
2021-08-23 15:24:05 +01:00
|
|
|
}`
|
|
|
|
{
|
2022-01-09 14:24:09 +00:00
|
|
|
param( [bool]$arg )
|
|
|
|
$this._showvbanchat = $this.Setter($this.cmd('DialogShow.VBANCHAT'), $arg)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_lock = $($this | Add-Member ScriptProperty 'lock' `
|
|
|
|
{
|
|
|
|
$this._lock = $this.Getter($this.cmd('lock'))
|
|
|
|
}`
|
|
|
|
{
|
|
|
|
param( [bool]$arg )
|
|
|
|
$this._lock = $this.Setter($this.cmd('lock'), $arg)
|
2021-08-23 15:24:05 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-01-19 19:06:41 +00:00
|
|
|
Function Make_Command {
|
2021-08-23 15:24:05 +01:00
|
|
|
return [Special]::new()
|
|
|
|
}
|