/// <summary> /// This method gets called once for each existing DiagnosticListener when this /// DiagnosticListener is added to the list of DiagnosticListeners /// (<see cref="System.Diagnostics.DiagnosticListener.AllListeners"/>). This method will /// also be called for each subsequent DiagnosticListener that is added to the list of /// DiagnosticListeners. /// <seealso cref="IObserver{T}.OnNext(T)"/> /// </summary> /// <param name="value">The DiagnosticListener that exists when this listener was added to /// the list, or a DiagnosticListener that got added after this listener was added.</param> public virtual void OnNext(DiagnosticListener value) { if (value == null || !this.IsSourceEnabled(value)) { return; } var eventHandler = this.GetEventHandler(value.Name); var manager = SubscriptionManagers.GetOrAdd(value.Name, k => new ActiveSubsciptionManager()); var individualListener = new IndividualDiagnosticSourceListener( value, eventHandler, this, this.GetListenerContext(value), manager); manager.Attach(individualListener); IDisposable subscription = value.Subscribe( individualListener, (evnt, input1, input2) => this.IsActivityEnabled(evnt, individualListener.Context) && eventHandler.IsEventEnabled(evnt, input1, input2)); this.individualSubscriptions.Enqueue(subscription); this.individualListeners.Enqueue(individualListener); }
/// <summary> /// This method gets called once for each existing DiagnosticListener when this /// DiagnosticListener is added to the list of DiagnosticListeners /// (<see cref="System.Diagnostics.DiagnosticListener.AllListeners"/>). This method will /// also be called for each subsequent DiagnosticListener that is added to the list of /// DiagnosticListeners. /// <seealso cref="IObserver{T}.OnNext(T)"/> /// </summary> /// <param name="value">The DiagnosticListener that exists when this listener was added to /// the list, or a DiagnosticListener that got added after this listener was added.</param> public virtual void OnNext(DiagnosticListener value) { if (value == null || !this.IsSourceEnabled(value)) { return; } var individualListener = new IndividualDiagnosticSourceListener(value, this, this.GetListenerContext(value)); IDisposable subscription = value.Subscribe( individualListener, (evnt, input1, input2) => this.IsEventEnabled(evnt, input1, input2, value, individualListener.Context)); if (this.individualSubscriptions == null) { this.individualSubscriptions = new List <IDisposable>(); } this.individualSubscriptions.Add(subscription); }