Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FilteredCustomHandler&lt;TDelegate&gt;"/> 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;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Builds strong-typed delegate of type <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">Delegate type.</typeparam>
 /// <returns>Delegate to call <see cref="InvokeClientDelegate"/> method.</returns>
 protected T BuildDelegate <T>()
 {
     return(DynamicWireFactory.BuildDelegate <T>(InvokeClientDelegateMethodInfo, this));
 }