GithubHelp home page GithubHelp logo

trackchange's Introduction

TrackChange

NuGet License MIT

This is an add-in for Fody.

Tracking POCO properties changes , easy to access what properties changed.

TrackChange will process any POCO class that mark as TrackingAttribute.

All trackable POCOs will be inject to implement ITrackable iterface , you can copy follow code in your project any where.

public class TrackingAttribute : Attribute
{
}


public interface ITrackable
{
    /// <summary>
    /// Modified name of Properties 
    /// </summary>
    Dictionary<string, bool> ModifiedProperties { get; set; }

    /// <summary>
    /// Is Track properties change state
    /// </summary>
    bool IsTracking { get; set; }
}

Installation

PM> Install-Package TrackChange.Fody

How it works

Your Code

[Tracking]
public class Class3
{
    public DateTime? Prop1 { get; set; }
    public string Test2 { get; set; }
    public int IntVal1 { get; set; }
    public int? IntVal2 { get; set; }
}

What gets compiled

[Tracking]
public class Class3 : ITrackable
{
    [NonSerialized]
    public virtual bool IsTracking { get; set; }

    [NonSerialized]
    public virtual Dictionary<string, bool> ModifiedProperties { get; set; } = new Dictionary<string, bool>();

    public DateTime? Prop1
    {
        [CompilerGenerated]
        get
        {
            return this.<Prop1>k__BackingField;
        }
        [CompilerGenerated]
        set
        {
            bool flag = object.Equals(this.Prop1, value);
            bool flag2 = !flag;
            if (flag2)
            {
                this.ModifiedProperties["Prop1"] = true;
            }
            this.<Prop1>k__BackingField = value;
        }
    }

    public string Test2
    {
        [CompilerGenerated]
        get
        {
            return this.<Test2>k__BackingField;
        }
        [CompilerGenerated]
        set
        {
            bool flag = object.Equals(this.Test2, value);
            bool flag2 = !flag;
            if (flag2)
            {
                this.ModifiedProperties["Test2"] = true;
            }
            this.<Test2>k__BackingField = value;
        }
    }

    public int IntVal1
    {
        [CompilerGenerated]
        get
        {
            return this.<IntVal1>k__BackingField;
        }
        [CompilerGenerated]
        set
        {
            bool flag = object.Equals(this.IntVal1, value);
            bool flag2 = !flag;
            if (flag2)
            {
                this.ModifiedProperties["IntVal1"] = true;
            }
            this.<IntVal1>k__BackingField = value;
        }
    }

    public int? IntVal2
    {
        [CompilerGenerated]
        get
        {
            return this.<IntVal2>k__BackingField;
        }
        [CompilerGenerated]
        set
        {
            bool flag = object.Equals(this.IntVal2, value);
            bool flag2 = !flag;
            if (flag2)
            {
                this.ModifiedProperties["IntVal2"] = true;
            }
            this.<IntVal2>k__BackingField = value;
        }
    }


}

trackchange's People

Contributors

jrt324 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.