update to class getters/setters and meta module

rename factory functions.

class getters now send is_string parameter.

each property type for each class now has separate meta function.
This commit is contained in:
onyx-and-iris
2022-01-19 21:52:59 +00:00
parent 84d31d3d61
commit 8e03c4e53b
6 changed files with 101 additions and 87 deletions

View File

@@ -1,25 +1,10 @@
. $PSScriptRoot\meta.ps1
class Special {
hidden AddPublicMembers($commands) {
$commands | ForEach-Object {
# Define getter
$GetterSignature = "`$this.Getter(`$this.cmd('{0}'))" -f $_
# Define setter
$SetterSignature = "`$this.Setter(`$this.cmd('{0}'))" -f $_
$AddMemberParams = @{
Name = $_
MemberType = 'ScriptProperty'
Value = [ScriptBlock]::Create($SetterSignature)
SecondValue = [ScriptBlock]::Create($GetterSignature)
}
$this | Add-Member @AddMemberParams
}
}
# Constructor
Special()
{
$this.AddPublicMembers(@('restart', 'shutdown', 'show'))
AddCommandMembers -PARAMS @('restart', 'shutdown', 'show')
}
[String] Getter($param) {