public MessageAttributeFilter GetSubscription(LogPublisherInternal publisher) { lock (m_syncRoot) { if (m_allSubscriptions == null) { m_allSubscriptions = new List <SubscriptionInfo>(); } MessageAttributeFilter filter = new MessageAttributeFilter(); foreach (var subscription in m_allSubscriptions) { if (subscription.PublisherFilter.ContainsPublisher(publisher)) { if (subscription.IsIgnoreSubscription) { filter.Remove(subscription.AttributeFilter); } else { filter.Append(subscription.AttributeFilter); } } } return(filter); } }
/// <summary> /// Subscribes to the publisher of the specified type expression with the specified verbose level. /// </summary> /// <param name="typeExpression">An expression of the name of a type. Must include a * or ? to be considered an expression.</param> /// <param name="level">The level</param> public void SubscribeToType(string typeExpression, VerboseLevel level) { if (typeExpression == null) { throw new ArgumentNullException(nameof(typeExpression)); } m_subscriber.Subscribe(PublisherFilter.CreateType(typeExpression), MessageAttributeFilter.Create(level), false); }
/// <summary> /// Ignore all messages of this verbose level. /// </summary> public void IgnoreAssembly(Assembly assembly, VerboseLevel level) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } m_subscriber.Subscribe(PublisherFilter.CreateAssembly(assembly), MessageAttributeFilter.Create(level), true); }
/// <summary> /// Ignore all messages of this verbose level. /// </summary> public void IgnoreType(Type type, VerboseLevel level) { if (type == null) { throw new ArgumentNullException(nameof(type)); } m_subscriber.Subscribe(PublisherFilter.CreateType(type), MessageAttributeFilter.Create(level), true); }
/// <summary> /// Adds/Modify/Deletes an existing subscription /// </summary> public void Subscribe(PublisherFilter publisherFilter, MessageAttributeFilter attributeFilter, bool isIgnoreSubscription) { if (publisherFilter == null) { throw new ArgumentNullException(nameof(publisherFilter)); } if (m_disposed) { return; } lock (m_syncRoot) { if (m_disposed) { return; } if (m_allSubscriptions == null) { if (attributeFilter == null) { return; } m_allSubscriptions = new List <SubscriptionInfo>(); m_allSubscriptions.Add(new SubscriptionInfo(publisherFilter, attributeFilter, isIgnoreSubscription)); } else { for (int x = 0; x < m_allSubscriptions.Count; x++) { if (m_allSubscriptions[x].PublisherFilter.ContainsTheSameLogSearchCriteria(publisherFilter)) { if (attributeFilter == null) { m_allSubscriptions.RemoveAt(x); return; } m_allSubscriptions[x].AttributeFilter = attributeFilter; m_allSubscriptions[x].IsIgnoreSubscription = isIgnoreSubscription; return; } } if (attributeFilter == null) { return; } m_allSubscriptions.Add(new SubscriptionInfo(publisherFilter, attributeFilter, isIgnoreSubscription)); } } m_recalculateRoutingTable(); }
public void Add(MessageAttributeFilter filter, LogSubscriberInternal subscriber) { Routes.Add(Tuple.Create(filter, subscriber.Reference)); Append(filter); }
/// <summary> /// Subscribes to all publishers with the specified verbose level. /// </summary> public void SubscribeToAll(VerboseLevel level) { m_subscriber.Subscribe(PublisherFilter.CreateUniversal(), MessageAttributeFilter.Create(level), false); }
/// <summary> /// Ignore all messages of this verbose level. /// </summary> public void IgnoreAll(VerboseLevel level) { m_subscriber.Subscribe(PublisherFilter.CreateUniversal(), MessageAttributeFilter.Create(level), true); }
public SubscriptionInfo(PublisherFilter publisherFilter, MessageAttributeFilter attributeFilter, bool isIgnoreSubscription) { PublisherFilter = publisherFilter; AttributeFilter = attributeFilter; IsIgnoreSubscription = isIgnoreSubscription; }