Project Description
A CustomTool for vs auto implementing interface based on aspects (auto INotifyPropertychanged implementation, auto command, dependency property mapping...).

How to
  • Step1: Add a new item to your project:
step1.png

  • Step2: Choose the WeavedType file:
step2.png

  • Step3: That's it!
    • The weaved file is added in code behind
    • The AopCore assembly contains specific InterfaceWeaver aspects
step3.png

INotifyPropertyChanged Auto implementation
Interface Declaration:
namespace Bench
{
    public interface IWeaveTest
    {
        /// <summary>
        /// The Name
        /// </summary>
        [ImplementINotifyPropertyChanged]
        string Name { get; set; }
    }
}

Resulting auto implementation:
namespace Bench
{
    using System.Windows.Input;
    using AopCore;
    
    
    public partial class WeaveTest : IWeaveTest, System.ComponentModel.INotifyPropertyChanged
    {
        
        private string name;
        
        /// <summary>
        /// The Name
        /// </summary>
        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                this.name = value;
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null))
                {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("Name"));
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
    }
}


Old property value check before notification
Interface declaration:
namespace Bench
{
    public interface IWeaveTest
    {
        /// <summary>
        /// The Name
        /// </summary>
        [ImplementINotifyPropertyChanged]
        [CheckPropertySetterChanges]
        string Name { get; set; }
    }
}

Resulting auto implementation:
namespace Bench
{
    using System.Windows.Input;
    using AopCore;
    
    
    public partial class WeaveTest : IWeaveTest, System.ComponentModel.INotifyPropertyChanged
    {
        
        private string name;
        
        /// <summary>
        /// The Name
        /// </summary>
        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                if ((this.name != value))
                {
                    this.name = value;
                    System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                    if ((propertyChanged != null))
                    {
                        propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("Name"));
                    }
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
    }
}

Aspects generalization and skip features
Interface Declaration:
namespace Bench
{
    [ImplementINotifyPropertyChanged]
    public interface IWeaveTest
    {
        /// <summary>
        /// The Id
        /// </summary>
        [SkipImplementINotifyPropertyChanged]
        int Id { get; set; }

        /// <summary>
        /// The Name
        /// </summary>
        string Name { get; set; }
    }
}

Resulting auto implementation:
namespace Bench
{
    using System.Windows.Input;
    using AopCore;
    
    
    public partial class WeaveTest : IWeaveTest, System.ComponentModel.INotifyPropertyChanged
    {
        private int Id;        

        private string name;

        /// <summary>
        /// The Id
        /// </summary>
        public int Id
        {
            get
            {
                return this.id;
            }
            set
            {
                this.id= value;
            }
        }
        
        /// <summary>
        /// The Name
        /// </summary>
        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                this.name = value;
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null))
                {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("Name"));
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
    }
}

... And many more features
... to come...

My Website.

Last edited Feb 8, 2013 at 2:29 PM by Charles_HETIER, version 15