public static IInterception Create(
            PropertyChangedInterceptor propertyChangedInterceptor,
            IInvocation invocation,
            NotifyMode fireOption)

        {
            switch (invocation)
            {
            case { } inv when inv.IsPropertyChangedAdd():
                return(new PropertyChangedAddInterception(propertyChangedInterceptor, inv));

            case { } inv when inv.IsPropertyChangedRemove():
                return(new PropertyChangedRemoveInterception(propertyChangedInterceptor, inv));

            case { } inv when inv.IsPropertySetter() && NotifyMode.OnlyOnChange == fireOption:
                return(new OnlyOnChangePropertySetterInterception(propertyChangedInterceptor, invocation)
                       .WrapWith(new PropertyIsINotifyInterception(propertyChangedInterceptor, invocation)));

            case { } inv when inv.IsPropertySetter():
                return(new PropertySetterInterception(propertyChangedInterceptor, invocation)
                       .WrapWith(new PropertyIsINotifyInterception(propertyChangedInterceptor, invocation)));

            default:
                return(new InvocationInterception(invocation));
            }
        }
        static void AddHandler(IInvocation invocation, PropertyChangedInterceptor propertyChangedInterceptor)
        {
            if (!handlers.ContainsKey(invocation.InvocationTarget))
                handlers.Add(invocation.InvocationTarget, new Dictionary<string, PropertyChangedEventHandler>());

            handlers[invocation.InvocationTarget].Add(invocation.PropertyName(), (o, e) =>
            {
                propertyChangedInterceptor.Notify(invocation);
                propertyChangedInterceptor.SetDependents(invocation);
            });

            (invocation.GetArgumentValue(0) as INotifyPropertyChanged).PropertyChanged += handlers[invocation.InvocationTarget][invocation.PropertyName()];
        }
 public static IInterception Create(PropertyChangedInterceptor propertyChangedInterceptor, IInvocation invocation, FireOptions fireOption, ILog log)
 {
     if(invocation.IsPropertyChangedAdd())
         return new PropertyChangedAddInterception(propertyChangedInterceptor, invocation);
     if(invocation.IsPropertyChangedRemove())
         return new PropertyChangedRemoveInterception(propertyChangedInterceptor, invocation);
     if(invocation.IsPropertySetter() && FireOptions.OnlyOnChange == fireOption)
         return new OnlyOnChangePropertySetterInterception(propertyChangedInterceptor, invocation, log).WrapWith(
             new PropertyIsINotifyInterception(propertyChangedInterceptor, invocation));
     if(invocation.IsPropertySetter())
         return new PropertySetterInterception(propertyChangedInterceptor, invocation).WrapWith(
             new PropertyIsINotifyInterception(propertyChangedInterceptor, invocation));
     return new InvocationInterception(invocation);
 }
 public PropertyChangedAddInterception(PropertyChangedInterceptor propertyChangedInterceptor, IInvocation invocation)
 {
     _propertyChangedInterceptor = propertyChangedInterceptor;
     _invocation = invocation;
 }
 public OnlyOnChangePropertySetterInterception(PropertyChangedInterceptor propertyChangedInterceptor, IInvocation invocation, ILog logger)
 {
     _propertyChangedInterceptor = propertyChangedInterceptor;
     _invocation = invocation;
     _logger = logger;
 }