/// <summary> /// Initializes a new instance of the <see cref="FilteredSystemEventHandler"/> class. /// </summary> /// <param name="eventHandler">The event handler.</param> /// <param name="eventFilter">The event filter.</param> /// <param name="filterLocally">Whether the filter should also work when used locally.</param> public FilteredSystemEventHandler(EventHandler eventHandler, IEventFilter eventFilter, bool filterLocally) { IEventFilter sourceFilter; ExtractSourceHandler(eventHandler, out eventHandler, out sourceFilter); EventHandler = eventHandler; EventFilter = eventFilter.Combine(sourceFilter); FilterLocally = filterLocally; }
/// <summary> /// Initializes a new instance of the <see cref="FilteredCustomHandler<TDelegate>"/> class. /// </summary> /// <param name="eventHandler">The event handler.</param> /// <param name="eventFilter">The event filter.</param> /// <param name="filterLocally">Whether the filter should also work when used locally.</param> public FilteredCustomHandler(TDelegate eventHandler, IEventFilter eventFilter, bool filterLocally) { if (!(eventHandler is Delegate)) { throw new ArgumentOutOfRangeException("eventHandler"); } IEventFilter sourceFilter; ExtractSourceHandler(eventHandler, out eventHandler, out sourceFilter); EventHandler = eventHandler; EventFilter = eventFilter.Combine(sourceFilter); // create strong-typed invoke method TypedInvoke = DynamicWireFactory.BuildInstanceDelegate <TDelegate>(InvokeMethodInfo, this); FilterLocally = filterLocally; }