Raise an event when Property Changed using Reflection

Posted by Dante on Stack Overflow See other posts from Stack Overflow or by Dante
Published on 2012-06-26T15:12:29Z Indexed on 2012/06/26 15:15 UTC
Read the original article Hit count: 230

Filed under:
|
|

I am working in C# and I have an object which I can only access using Reflection (for some personal reasons). So, when I need to set some value to one of its properties I do as below:

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

And, to get its value I use the method GetValue.

My question is: Is there a way to fire an event when the property changes using Reflection?

Thank you in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection