i would like to run a method, every time certain values are changed on a object.
I was wondering if i could create a Custom attribute to add to the values i want to trigger my method, when their value is changed.
Fx:
public class Program
{
public static void Main()
{
A a = new A("Hello", true);
a.text = "Goodbye";
a.check = false;
}
}
public class A{
public string text {get; set;}
[RunMyMethod]
public bool check {get; set;}
public A(string t, bool c){
this.text = t;
this.check = c;
}
}
public class RunMyMethod : System.Attribute
{
}
I am aware of the fact that i simply just go add something to every fields Set method, but the class i want to implement this on, is rather huge, and it wouldn't be pretty.