/// <summary> /// Handles the publisher. /// </summary> /// <param name="publisher">The publisher.</param> /// <param name="register">true to register publications, false to unregister them.</param> /// <param name="eventInfo">The published event..</param> /// <param name="attr">The attribute</param> /// <param name="eventTopicHost">The event topic host.</param> private void HandlePublisher( object publisher, bool register, EventInfo eventInfo, EventPublicationAttribute attr, IEventTopicHost eventTopicHost) { IEventTopic topic = eventTopicHost.GetEventTopic(attr.Topic); if (register) { List <IPublicationMatcher> matchers = new List <IPublicationMatcher>(); foreach (Type type in attr.MatcherTypes) { matchers.Add(this.factory.CreatePublicationMatcher(type)); } topic.AddPublication( publisher, eventInfo, attr.HandlerRestriction, matchers); } else { topic.RemovePublication(publisher, eventInfo); } }
/// <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> /// 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); } }
/// <summary> /// Processes the publisher. /// </summary> /// <param name="topic">The topic.</param> /// <param name="publisher">The publisher.</param> /// <param name="eventName">Name of the event.</param> /// <param name="handlerRestriction">The handler restriction.</param> /// <param name="matchers">The matchers.</param> /// <param name="register">true to register publications, false to unregister them.</param> /// <param name="eventTopicHost">The event topic host.</param> public void ProcessPublisher(string topic, object publisher, string eventName, HandlerRestriction handlerRestriction, IList <IPublicationMatcher> matchers, bool register, IEventTopicHost eventTopicHost) { EventInfo eventInfo = publisher.GetType().GetEvent(eventName); if (eventInfo == null) { throw new PublisherEventNotFoundException(publisher.GetType(), eventName); } IEventTopic eventTopic = eventTopicHost.GetEventTopic(topic); if (register) { eventTopic.AddPublication(publisher, eventInfo, handlerRestriction, matchers); } else { eventTopic.RemovePublication(publisher, eventInfo); } }