I would like to know if there is any way to add custom behaviour to the auto property get/set methods.
An obvious case I can think of is wanting every set property method to call on any PropertyChanged
event handlers as part of a System.ComponentModel.INotifyPropertyChanged
implementation. This would allow a class to have numerous properties that can be observed, where each property is defined using auto property syntax.
Basically I'm wondering if there is anything similar to either a get/set template or post get/set hook with class scope.
(I know the same end functionality can easily be achieved in slightly more verbose ways - I just hate duplication of a pattern)
No, you'll have to use "traditional" property definitions for custom behavior.
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) | Powered by Discuz! X3.4 |