I want to simplify the property declarations in my classes. The problem is the getter and setter definition. I am doing exactly the same for hundreds of properties. All properties are created like this, where the method "LogPropertyChanged" also RaisePropertyChange.
public class PCS_MA_V1_ALARMSTAT : ViewModelBase
{
private Boolean _ActionAlarmHighHigh;
public Boolean ActionAlarmHighHigh
{
get
{
return _ActionAlarmHighHigh;
}
set
{
if(value!= _ActionAlarmHighHigh)
{
_ActionAlarmHighHigh = value;
LogpropertyChanged("ActionAlarmHighHigh", oldVal, newVal);
}
}
}
private Boolean _ActionAlarmLowLow;
public Boolean ActionAlarmLowLow
{
get
{
return _ActionAlarmLowLow;
}
set
{
if(value!= _ActionAlarmLowLow)
{
_ActionAlarmLowLow = value;
LogpropertyChanged("ActionAlarmLowLow", oldVal, newVal);
}
}
}
}
Now i think this syntax is much to complex, and a huge hasle to work with. Is there a way where i could create the class like this:
public class PCS_MA_V1_ALARMSTAT: ViewModelBase
{
public Boolean ActionAlarmHighHigh { get; set; }
public Boolean ActionAlarmLowLow { get; set; }
}
And then monitor the instance. If a property has changed i run LogPropertyChanged on that particular property. Is this possible?