Пример #1
0
        /// <summary>
        ///     Removes a subscription.
        /// </summary>
        /// <typeparam name="ContextItemType">The type of context item to remove the callback from.</typeparam>
        /// <param name="callback">The callback to remove.</param>
        /// <exception cref="ArgumentNullException">if callback is null.</exception>
        public void Unsubscribe <TContextItemType>(SubscribeContextCallback <TContextItemType> callback) where TContextItemType : ContextItem
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            var proxy = new SubscribeProxy <TContextItemType>(callback);

            Unsubscribe(typeof(TContextItemType), proxy.Callback);
        }
        public void Unsubscribe <TServiceType>(SubscribeServiceCallback <TServiceType> callback)
        {
            if (callback == null)
            {
                throw FxTrace.Exception.ArgumentNull("callback");
            }
            SubscribeProxy <TServiceType> proxy = new SubscribeProxy <TServiceType>(callback);

            Unsubscribe(typeof(TServiceType), proxy.Callback);
        }
        public void Subscribe <TContextItemType>(SubscribeContextCallback <TContextItemType> callback) where TContextItemType : ContextItem
        {
            if (callback == null)
            {
                throw FxTrace.Exception.ArgumentNull("callback");
            }
            SubscribeProxy <TContextItemType> proxy = new SubscribeProxy <TContextItemType>(callback);

            Subscribe(typeof(TContextItemType), proxy.Callback);
        }
        public void Subscribe <TServiceType>(SubscribeServiceCallback <TServiceType> callback)
        {
            if (callback == null)
            {
                throw FxTrace.Exception.ArgumentNull("callback");
            }

            // Call the standard Subscribe method and use a generic proxy
            SubscribeProxy <TServiceType> proxy = new SubscribeProxy <TServiceType>(callback);

            Subscribe(typeof(TServiceType), proxy.Callback);
        }