Click here to Skip to main content
15,888,020 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,

I have a code like this:
C#
public abstract class Entity
{
}

public class Student : Entity
{
    public int StudentNo { get; set; }
    public string FirstName { get; set; }
    public string MiddleName { get; set; }
    public string LastName { get; set; }
}


I need to raise a same event in each set method of all the Student class property. I have many class like that and It'll take a lot of time and effort by manually entering code to the set accessor of each property.

I can use reflection in the constructor of the base class Entity but I can't see any method in PropertyInfo.GetSetMethod() that can add a line of code that will raise that event.

Please I need your help.
Thanks in advance..
Posted
Updated 14-Dec-11 18:00pm
v2

1 solution

Implement INotifyPropertyChanged[^] on your base class and handle the PropertyChanged event
 
Share this answer
 
Comments
unknowndentified10111 14-Dec-11 22:57pm    
Actually I'm implementing the INotifyPropertyChanged in my base class but I still need to add a line of code in the set accessor of the properties of the concrete class that will call the method that raises the PropertyChange event handler. Still this same question will arise.
[no name] 14-Dec-11 23:10pm    
Guess you should have planned for this in the beginning. Changing a design takes work
unknowndentified10111 14-Dec-11 23:14pm    
Is there really no other way? :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900