refactored to use identifier()

This commit is contained in:
onyx-and-iris 2022-12-16 17:27:05 +00:00
parent c999e73e14
commit ec296059d4

View File

@ -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)
}
}