I've defined a custom ValidateSet parameter attribute like so:
Class MyValidValuesAttribute : System.Management.Automation.IValidateSetValuesGenerator {
[string[]] GetValidValues() { return [string[]]'MyValidValueA','MyValidValueB' }
}
I'd like to avoid having to instantiate the class just to return the set of valid values.
I'd simply call [MyValidValuesAttribute]::GetValidValues() instead of the two-line
$X = [MyValidValuesAttribute]::new()
$Y = $X.GetValidValues()
but that method must not be static or the class will not implement the interface.
Is there any way to make a method work the same way regardless of whether the class has been instantiated under the same name? I know I could just implement GetValidValues_Static; wondering if a more elegant solution exists.