我工作在C#更改的属性的时候,我有我只能访问使用Reflection
(对于某些个人原因)的对象。所以,当我需要一些值设置其属性之一,我做如下:引发事件使用反射
System.Reflection.PropertyInfo property = this.Parent.GetType().GetProperty("SomeProperty");
object someValue = new object(); // Just for example
property.SetValue(this.Parent, someValue, null);
而且,为了得到它的价值我使用的方法GetValue
。
我的问题是:有没有办法使用反射属性的变化时触发一个事件?
预先感谢您。
?调用SetValue应该使用属性设置器。 – cadrell0
@ cadrell0,不,不怕 – Dante
@丹特,你找到了解决方案吗?我尝试触发通知事件时,Thread.CurrentThread.CurrentCulture价值改变这是类似于你的问题 – Kira