From ec296059d4cbe6028c5fe56ad7959d07f6f2af2a Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 16 Dec 2022 17:27:05 +0000 Subject: [PATCH] refactored to use identifier() --- lib/command.ps1 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/command.ps1 b/lib/command.ps1 index e85392c..1919925 100644 --- a/lib/command.ps1 +++ b/lib/command.ps1 @@ -6,56 +6,56 @@ class Special { AddActionMembers -PARAMS @('restart', 'shutdown', 'show') } + [string] identifier () { + return "Command" + } + [string] ToString() { return $this.GetType().Name } - [single] Getter ($cmd) { - return Param_Get -PARAM $cmd -IS_STRING $false + [single] Getter ($param) { + return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false } [void] Setter ($param, $val) { if ($val -is [Boolean]) { - Param_Set -PARAM $param -Value $(if ($val) { 1 } else { 0 }) + Param_Set -PARAM "$($this.identifier()).$param" -Value $(if ($val) { 1 } else { 0 }) } else { - Param_Set -PARAM $param -Value $val + Param_Set -PARAM "$($this.identifier()).$param" -Value $val } } - [string] cmd ($arg) { - return "Command.$arg" - } - hidden $_hide = $($this | Add-Member ScriptProperty 'hide' ` { - $this._hide = $this.Setter($this.cmd('show'), $false) + $this._hide = $this.Setter('show', $false) } ` {} ) hidden $_showvbanchat = $($this | Add-Member ScriptProperty 'showvbanchat' ` { - $this.Getter($this.cmd('DialogShow.VBANCHAT')) + $this.Getter('DialogShow.VBANCHAT') } ` { param([bool]$arg) - $this._showvbanchat = $this.Setter($this.cmd('DialogShow.VBANCHAT'), $arg) + $this._showvbanchat = $this.Setter('DialogShow.VBANCHAT', $arg) } ) hidden $_lock = $($this | Add-Member ScriptProperty 'lock' ` { - $this._lock = $this.Getter($this.cmd('lock')) + $this._lock = $this.Getter('lock') } ` { param([bool]$arg) - $this._lock = $this.Setter($this.cmd('lock'), $arg) + $this._lock = $this.Setter('lock', $arg) } ) [void] Load ([string]$filename) { - $this.Setter($this.cmd('load'), $filename) + $this.Setter('load', $filename) } }