/// <summary> /// Gets the handlers of this even topic /// </summary> /// <returns> /// Array of delegates, the handlers for this even topic. /// </returns> private IEnumerable <KeyValuePair <ISubscription, EventTopicFireDelegate> > GetHandlers() { foreach (ISubscription subscription in this.subscriptions) { EventTopicFireDelegate handler = subscription.GetHandler(); if (handler != null) { yield return(new KeyValuePair <ISubscription, EventTopicFireDelegate>(subscription, handler)); } } }
public EventTopicFireDelegate[] GetHandlers() { List <EventTopicFireDelegate> result = new List <EventTopicFireDelegate>(); lock (lockObject) { foreach (Subscription subscription in subscriptions.ToArray()) { EventTopicFireDelegate handler = subscription.GetHandler(); if (handler != null) { result.Add(handler); } } return(result.ToArray()); } }
/// <summary> /// Calls the subscription handlers. /// </summary> /// <param name="sender">The publisher.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <param name="handlers">The handlers to call.</param> /// <param name="publication">The publication firing the event topic.</param> private void CallSubscriptionHandlers(object sender, EventArgs e, IEnumerable <KeyValuePair <ISubscription, EventTopicFireDelegate> > handlers, IPublication publication) { foreach (var handler in handlers) { ISubscription subscription = handler.Key; EventTopicFireDelegate handlerMethod = handler.Value; if (this.CheckMatchers(publication, subscription, e)) { handlerMethod(this, sender, e, publication); } else { this.extensionHost.ForEach(extension => extension.SkippedEvent( this, publication, subscription, sender, e)); } } }
private void CallSubscriptionHandlers(object sender, EventArgs e, EventTopicFireDelegate[] handlers) { List<Exception> exceptions = new List<Exception>(); foreach (EventTopicFireDelegate handler in handlers) { handler(sender, e, exceptions, traceSource); } if (exceptions.Count > 0) { TraceExceptions(exceptions); throw new EventTopicException(this, new ReadOnlyCollection<Exception>(exceptions)); } }