Пример #1
0
        /// <summary>
        /// Handles the subscriber.
        /// </summary>
        /// <param name="subscriber">The subscriber.</param>
        /// <param name="register">true to register subscriptions, false to unregister them.</param>
        /// <param name="methodInfo">The handler method.</param>
        /// <param name="attr">The subscription attribute.</param>
        /// <param name="eventTopicHost">The event topic host.</param>
        private void HandleSubscriber(
            object subscriber,
            bool register,
            MethodInfo methodInfo,
            EventSubscriptionAttribute attr,
            IEventTopicHost eventTopicHost)
        {
            IEventTopic topic = eventTopicHost.GetEventTopic(attr.Topic);

            if (register)
            {
                List <ISubscriptionMatcher> matchers = new List <ISubscriptionMatcher>();
                foreach (Type type in attr.MatcherTypes)
                {
                    matchers.Add(this.factory.CreateSubscriptionMatcher(type));
                }

                topic.AddSubscription(
                    subscriber,
                    methodInfo,
                    this.factory.CreateHandler(attr.HandlerType),
                    matchers);
            }
            else
            {
                topic.RemoveSubscription(subscriber, methodInfo);
            }
        }
Пример #2
0
        /// <summary>
        /// Removes a subscription.
        /// </summary>
        /// <typeparam name="TEventArgs">The type of the event arguments.</typeparam>
        /// <param name="topic">The topic.</param>
        /// <param name="subscriber">The subscriber.</param>
        /// <param name="handlerMethod">The handler method.</param>
        public void RemoveSubscription <TEventArgs>(string topic, object subscriber, EventHandler <TEventArgs> handlerMethod) where TEventArgs : EventArgs
        {
            Ensure.ArgumentNotNull(handlerMethod, "handlerMethod");

            IEventTopic eventTopic = this.eventTopicHost.GetEventTopic(topic);

            eventTopic.RemoveSubscription(subscriber, handlerMethod.Method);
        }
Пример #3
0
        /// <summary>
        /// Removes a subscription.
        /// </summary>
        /// <typeparam name="TEventArgs">The type of the event arguments.</typeparam>
        /// <param name="topic">The topic.</param>
        /// <param name="subscriber">The subscriber.</param>
        /// <param name="handlerMethod">The handler method.</param>
        public void RemoveSubscription <TEventArgs>(string topic, object subscriber, EventHandler <TEventArgs> handlerMethod) where TEventArgs : EventArgs
        {
            Guard.AgainstNullArgument(nameof(handlerMethod), handlerMethod);

            IEventTopic eventTopic = this.eventTopicHost.GetEventTopic(topic);

            eventTopic.RemoveSubscription(subscriber, handlerMethod.Method);
        }
Пример #4
0
        private void UnregisterPropertySubscriptions(object subscriber, IEnumerable <PropertySubscriptionScanResult> propertySubscriptions)
        {
            foreach (PropertySubscriptionScanResult propertySubscription in propertySubscriptions)
            {
                IEventTopic topic = this.eventTopicHost.GetEventTopic(propertySubscription.Topic);

                topic.RemoveSubscription(subscriber, propertySubscription.Method);
            }
        }
Пример #5
0
        /// <summary>
        /// Handles the subscriber.
        /// </summary>
        /// <param name="eventTopicHost">The event topic host.</param>
        /// <param name="topic">The topic.</param>
        /// <param name="register">if set to <c>true</c> [register].</param>
        /// <param name="subscriber">The subscriber.</param>
        /// <param name="handlerMethod">The handler method.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="matchers">The matchers.</param>
        private void HandleSubscriber(IEventTopicHost eventTopicHost, string topic, bool register, object subscriber, MethodInfo handlerMethod, IHandler handler, ISubscriptionMatcher[] matchers)
        {
            IEventTopic eventTopic = eventTopicHost.GetEventTopic(topic);

            if (register)
            {
                eventTopic.AddSubscription(subscriber, handlerMethod, handler, matchers);
            }
            else
            {
                eventTopic.RemoveSubscription(subscriber, handlerMethod);
            }
        }
Пример #6
0
        private void RemoveSubscription(string topic, object subscriber, MethodInfo methodInfo)
        {
            IEventTopic eventTopic = this.eventTopicHost.GetEventTopic(topic);

            eventTopic.RemoveSubscription(subscriber, methodInfo);
        }
Пример #7
0
        /// <summary>
        /// Removes a subscription.
        /// </summary>
        /// <param name="topic">The topic.</param>
        /// <param name="subscriber">The subscriber.</param>
        /// <param name="handlerMethod">The handler method.</param>
        public void RemoveSubscription(string topic, object subscriber, EventHandler handlerMethod)
        {
            IEventTopic eventTopic = this.eventTopicHost.GetEventTopic(topic);

            eventTopic.RemoveSubscription(subscriber, handlerMethod.Method);
        }