Is it possible to implement Property Changed as Attribute?

前端 未结 2 1282
渐次进展
渐次进展 2021-01-20 15:19

I have found an implementation of Propperty Changed Event, where i can Call Property changed without the Name of the Property in the web. And then i have build a Extension M

相关标签:
2条回答
  • 2021-01-20 15:30

    Check out Fody, and the PropertyChanged add-in. It will modify the IL after compilation to add the code to raise the PropertyChanged event for your properties. It's similar to PostSharp, mentioned in Lasse's answer, but it's free and open-source.

    0 讨论(0)
  • 2021-01-20 15:43

    You will need some kind of AOP system to do this.

    Either something where you wrap or inherit from your class, and dynamically generate the necessary plumbing in the wrapper/descendant to handle this, or some system like Postsharp that rewrites your code after compilation.

    There is nothing built into .NET to handle this.

    0 讨论(0)
提交回复
热议问题