private void RegisterEvent(object obj, string eventName) { EventInfo @event = obj.GetType().GetEvent(eventName); if (@event == null) { if (this.SourceObject != null) { CultureInfo currentCulture = CultureInfo.CurrentCulture; string eventTriggerCannotFindEventNameExceptionMessage = ExceptionStringTable.EventTriggerCannotFindEventNameExceptionMessage; object[] objArray = new object[] { eventName, obj.GetType().Name }; throw new ArgumentException(string.Format(currentCulture, eventTriggerCannotFindEventNameExceptionMessage, objArray)); } return; } if (EventTriggerBase.IsValidEvent(@event)) { this.eventHandlerMethodInfo = typeof(EventTriggerBase).GetMethod("OnEventImpl", BindingFlags.Instance | BindingFlags.NonPublic); @event.AddEventHandler(obj, Delegate.CreateDelegate(@event.EventHandlerType, this, this.eventHandlerMethodInfo)); return; } if (this.SourceObject != null) { CultureInfo cultureInfo = CultureInfo.CurrentCulture; string eventTriggerBaseInvalidEventExceptionMessage = ExceptionStringTable.EventTriggerBaseInvalidEventExceptionMessage; object[] objArray1 = new object[] { eventName, obj.GetType().Name }; throw new ArgumentException(string.Format(cultureInfo, eventTriggerBaseInvalidEventExceptionMessage, objArray1)); } }
private static void OnSourceObjectChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { EventTriggerBase eventTriggerBase = (EventTriggerBase)obj; object obj1 = eventTriggerBase.SourceNameResolver.Object; if (args.NewValue == null) { eventTriggerBase.OnSourceChanged(args.OldValue, obj1); return; } if (args.OldValue == null && obj1 != null) { eventTriggerBase.UnregisterEvent(obj1, eventTriggerBase.GetEventName()); } eventTriggerBase.OnSourceChanged(args.OldValue, args.NewValue); }
private static void OnSourceObjectChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { EventTriggerBase eventTriggerBase = (EventTriggerBase)obj; object @object = eventTriggerBase.SourceNameResolver.Object; if (args.NewValue == null) { eventTriggerBase.OnSourceChanged(args.OldValue, @object); } else { if (args.OldValue == null && @object != null) { eventTriggerBase.UnregisterEvent(@object, eventTriggerBase.GetEventName()); } eventTriggerBase.OnSourceChanged(args.OldValue, args.NewValue); } }
private static void OnSourceNameChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { EventTriggerBase eventTriggerBase = (EventTriggerBase)obj; eventTriggerBase.SourceNameResolver.Name = (string)args.NewValue; }