Skip to content

pH200/PropertyChanging.ReactiveUI.WinRT

 
 

Repository files navigation

This is an add-in for Fody

Icon

Injects INotifyPropertyChanging code into properties at compile time.

Introduction to Fody

Nuget

Nuget package http://nuget.org/packages/PropertyChanging.Fody

To Install from the Nuget Package Manager Console

PM> Install-Package PropertyChanging.Fody

Your Code

[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);
        }
    }

}

What gets compiled

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

Icon courtesy of The Noun Project

Contributors

More Info

About

Injects INotifyPropertyChanging code into properties at compile time.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 98.3%
  • PowerShell 1.4%
  • F# 0.3%