ppittle / pMixins

pMixins - Mixin framework for C#
http://pMixins.com
Apache License 2.0
23 stars 5 forks source link

Create INotifyPropertyChanged tests / documentation #18

Open ppittle opened 10 years ago

ppittle commented 10 years ago

Note: This will need to wait for the IMixinDependency to be implemented in the main code base. Note: This may also require events to be mixed in.

public class NotifyPropertyChangedMixin : INotifyPropertyChanged
{
     public event PropertyChangedEventHandler PropertyChanged;
}

public class NotifyPropertyChangedAspect : MixinInterceptorBase, IMixinDependency<INotifyPropertyChanged>
{
    public INotifyPropertyChanged Target {get;set;}

    public override void OnAfterPropertyInvocation(object sender, PropertyEventArgs eventArgs)
    {
            Target.PropertyChanged(Target, new PRopertyChangedEventArgs(eventArgs.MemberName);
     }
}

[pMixins(Mixin = typeof(NotifyPropertyChangedMixin )]
[pMixins(Mixin = typeof(Target.TargetImpl), Interceptors = new []{typeof(NotifyPropertyChangedAspect )]
public partial class Target
{
    private class TargetImpl
    {
          public string SomeProperty {get;set;}
    }
}