private bool AddSubscription(EventProviderSubscription subscription)
        {
            if (subscription.Name == null && subscription.ProviderID == Guid.Empty)
            {
                throw new InvalidConfigurationException("Provided subscription missing name and GUID values");
            }

            var newSubscription = true;

            if (this.subscriptions.Contains(subscription))
            {
                newSubscription = false;
                var currentSubscription = this.subscriptions.First(s => s.Equals(subscription));
                currentSubscription.MinimumLevel =
                    (EventLevel)Math.Max((int)currentSubscription.MinimumLevel, (int)subscription.MinimumLevel);
                currentSubscription.Keywords |= subscription.Keywords;
            }
            else
            {
                this.subscriptions.Add(subscription);
            }

            return(newSubscription);
        }
コード例 #2
0
        public void SubscribeToEvents(EventProviderSubscription subscription)
        {
            if (subscription == null)
            {
                throw new ArgumentNullException("subscription");
            }

            if (subscription.Source != null)
            {
                this.SubscribeToEvents(subscription.Source.Guid, subscription.MinimumLevel, subscription.Keywords);
            }
            else
            {
                this.SubscribeToEvents(subscription.ProviderID, subscription.MinimumLevel, subscription.Keywords);
            }
        }
 private bool Equals(EventProviderSubscription other)
 {
     return(this.ProviderID.Equals(other.ProviderID) &&
            string.Equals(this.Name, other.Name, StringComparison.OrdinalIgnoreCase));
 }
コード例 #4
0
        public void SubscribeToEvents(EventProviderSubscription subscription)
        {
            if (subscription == null)
            {
                throw new ArgumentNullException("subscription");
            }

            if (subscription.Source != null)
            {
                this.SubscribeToEvents(subscription.Source, subscription.MinimumLevel, subscription.Keywords);
            }
            else
            {
                throw new NotSupportedException("Subscription to GUIDs is not supported");
            }
        }