AOP w/ PostSharp - 经典 NotifyPropertyChanged PropertyChanged 事件处理程序丢失?
PostSharp 2.0 新手并尝试此处提供的 NotifyPropertyChanged AOP 类: http://www.sharpcrafters.com/solutions/ui#undo-redo
当我尝试挂钩 PropertyChanged 事件处理程序时,编译器告诉我它尚未定义。我没有直接在相关对象上实现 INotifyPropertyChanged 接口,只应用了属性。
我假设答案是实现接口,但这有点破坏了简单性,我是否遗漏了一些东西,或者这也是一个要求?
有没有办法让PostSharp修改类预编译来引入这些成员/接口?
New to PostSharp 2.0 and trying out the class NotifyPropertyChanged AOP provided here:
http://www.sharpcrafters.com/solutions/ui#undo-redo
When I attempt to hook into the PropertyChanged event handler the compiler tells me it is not defined. I have not directly implemented the INotifyPropertyChanged interface on the object in question, only applied the attribute.
I would assume the answer is to implement the interface but this defeats the simplicity a bit, am I missing something or is that also a requirement?
Is there any way to get PostSharp to modify the class pre-compile to introduce these members/interfaces?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想,您正在尝试订阅同一程序集中的事件。 PostSharp 会在编译后重写您的程序集。因此,只有当您引用已由 PostSharp 二进制重写器重写的程序集时,这才有效。
I suppose, you are trying to subscribe to the event in the same assembly. PostSharp is rewriting your assembly after it has been compiled. So this will only work, if you reference the assembly that has been rewritten by the PostSharp binary rewriter.