Project DescriptionA 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:
- Step2: Choose the WeavedType file:
- Step3: That's it!
- The weaved file is added in code behind
- The AopCore assembly contains specific InterfaceWeaver aspects
INotifyPropertyChanged Auto implementationInterface 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 notificationInterface 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 featuresInterface 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.