/// <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); } }
/// <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); }
/// <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); }
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); } }
/// <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); } }
private void RemoveSubscription(string topic, object subscriber, MethodInfo methodInfo) { IEventTopic eventTopic = this.eventTopicHost.GetEventTopic(topic); eventTopic.RemoveSubscription(subscriber, methodInfo); }
/// <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); }