private void RaiseEvent(IPipelineEvent @event, bool ignoreAbort = false) { ObservedEvents.TryGetValue(@event.GetType(), out var observersForEvent); if (observersForEvent == null || observersForEvent.Count == 0) { return; } foreach (var observerPair in observersForEvent) { var observer = observerPair.PipelineObserver; if (_log.IsVerboseEnabled) { _log.Verbose(string.Format(_raisingPipelineEvent, @event.Name, StageName, observer.GetType().FullName)); } try { observerPair.MethodInfo.Invoke(observer, new object[] { @event }); } catch (Exception ex) { throw new PipelineException( string.Format(_raisingPipelineEvent, @event.Name, StageName, observer.GetType().FullName), ex); } if (Aborted && !ignoreAbort) { return; } } }
public static void Register(this Pipeline pipeline, IPipelineEvent @event) { string eventName = @event.GetType().Name; if (pipeline.Events.ContainsKey(eventName)) { return; } pipeline.Events.Add(eventName, @event); }