This is an add-in for Fody
Injects INotifyPropertyChanging code into properties at compile time.
Nuget package http://nuget.org/packages/PropertyChanging.Fody
To Install from the Nuget Package Manager Console
PM> Install-Package PropertyChanging.Fody
[ImplementPropertyChanging]
public class Person
{
public string GivenNames { get; set; }
public string FamilyName { get; set; }
public string FullName
{
get
{
return string.Format("{0} {1}", GivenNames, FamilyName);
}
}
}
public class Person : INotifyPropertyChanging
{
public event PropertyChangingEventHandler PropertyChanging;
string givenNames;
public string GivenNames
{
get { return givenNames; }
set
{
if (value != givenNames)
{
OnPropertyChanging("GivenNames");
OnPropertyChanging("FullName");
givenNames = value;
}
}
}
string familyName;
public string FamilyName
{
get { return familyName; }
set
{
if (value != familyName)
{
OnPropertyChanging("FamilyName");
OnPropertyChanging("FullName");
familyName = value;
}
}
}
public string FullName
{
get
{
return string.Format("{0} {1}", GivenNames, FamilyName);
}
}
public virtual void OnPropertyChanging(string propertyName)
{
var propertyChanging = PropertyChanging;
if (propertyChanging != null)
{
propertyChanging(this, new PropertyChangingEventArgs(propertyName));
}
}
}
Icon courtesy of The Noun Project