使用Reflection更改属性时引发事件

Dan*_*nte 7 c# reflection propertychanged

我在C#工作,我有一个我只能使用的对象Reflection(出于某些个人原因).所以,当我需要为其中一个属性设置一些值时,我会按如下方式执行:

System.Reflection.PropertyInfo property = this.Parent.GetType().GetProperty("SomeProperty");
object someValue = new object(); // Just for example
property.SetValue(this.Parent, someValue, null);
Run Code Online (Sandbox Code Playgroud)

并且,为了获得它的价值,我使用了这个方法GetValue.

我的问题是:当使用Reflection更改属性时,是否有办法触发事件?

Jon*_*eet 8

有没有办法在使用Reflection更改属性时触发事件?

除非财产制定者自己提出它,否则不会.没有什么能够"观察"所有属性的变化,并且当它们发生时会引发事件.