public override void Intercept(IInvocation invocation) { // Get all the set attributes. // AllowMultiple = true HandleEventsAttribute[] attributes = ProxyCommon.AsAttribute <HandleEventsAttribute[]>(invocation.Method); // The attribute can only be applied to Properties that are objects and have a getter. if (attributes == null || attributes.Length == 0) { invocation.Proceed(); return; } if (ProxyCommon.GetMethodResult(invocation, $"get_{attributes[0].MemberName}") != null) { // Need to remove the listeners before changing the object. EditEvents(attributes, invocation, /*removeEvent*/ true); } invocation.Proceed(); if (ProxyCommon.GetMethodResult(invocation, $"get_{attributes[0].MemberName}") != null) { // Need to add the listeners on new object EditEvents(attributes, invocation, /*removeEvent*/ false); } }
public void Intercept(IInvocation invocation) { invocation.Proceed(); BaseNotifyPropertyChangedAttribute attribute = ProxyCommon.AsAttribute <BaseNotifyPropertyChangedAttribute>(invocation.Method); if (attribute != null) { BaseNotifyPropertyChanged @base = invocation.InvocationTarget as BaseNotifyPropertyChanged; foreach (string property in attribute.PropertiesToNotify) { @base.OnPropertyChanged(property); } } }
public void Intercept(IInvocation invocation) { // Get all the set attributes. HandleEventsAttribute[] attributes = ProxyCommon.AsAttribute <HandleEventsAttribute[]>(invocation.Method); // The attribute can only be applied to Properties that are objects and have a getter. if (attributes == null || attributes.Length == 0) { invocation.Proceed(); return; } if (GetMethod(invocation, $"get_{attributes[0].MemberName}") != null) { // Need to remove the listeners before changing the object. foreach (HandleEventsAttribute attribute in attributes) { EditEvent ( attribute.MemberName, attribute.EventName, attribute.MethodName, invocation.InvocationTarget, /*removeEvent*/ true ); } } invocation.Proceed(); if (GetMethod(invocation, $"get_{attributes[0].MemberName}") != null) { // Need to add the listeners on new object foreach (HandleEventsAttribute attribute in attributes) { EditEvent ( attribute.MemberName, attribute.EventName, attribute.MethodName, invocation.InvocationTarget, /*removeEvent*/ false ); } } }