-
-
Notifications
You must be signed in to change notification settings - Fork 17
Home
Simon Cropp edited this page Jul 30, 2012
·
5 revisions
This is an add-in for Fody
Injects INotifyPropertyChanging code into properties at compile time.
Nuget package http://nuget.org/packages/PropertyChanging.Fody
public class Person : INotifyPropertyChanging
{
public event PropertyChangingEventHandler PropertyChanged;
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));
}
}
}