问题
Does anyone know if the INotifyPropertyChanged interface can be implemented on an object in Powershell natively, without building a C# class and using Add-Type to generate a new .NET assembly?
I've Googled everything I can think of and haven't been able to find a solution.
Thanks.
回答1:
No. Consider PowerShell a CLI consumer language and not so much a producer language. That is you can construct and use most .NET types. However PowerShell doesn't natively provide a facility to create new .NET types much less types that implement interfaces. While you can create custom objects in PowerShell and use tricks to give those objects a type name that PowerShell understands, those tricks don't work with .NET libraries like WPF.
来源:https://stackoverflow.com/questions/21814444/powershell-can-inotifypropertychanged-be-implemented-natively