void MatchQueue(MatchState state)
        {
            MsmqBindingFilter bestMatch = state.LastMatch;
            int bestMatchLength         = state.LastMatchLength;

            // look through all the filters for the largest match:
            foreach (MsmqBindingFilter filter in this.filters)
            {
                int matchLength = filter.Match(state.QueueName);
                if (matchLength > bestMatchLength)
                {
                    bestMatchLength = matchLength;
                    bestMatch       = filter;
                }
            }

            if (bestMatch != state.LastMatch)
            {
                if (state.LastMatch != null)
                {
                    state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
                }

                state.LastMatchLength = bestMatchLength;
                state.LastMatch       = bestMatch;

                state.CallbackState = bestMatch.MatchFound(this.host, state.QueueName, state.IsPrivate);
            }
        }
 public bool ContainsFilter(MsmqBindingFilter filter)
 {
     lock (this.thisLock)
     {
         return this.filters.Contains(filter);
     }
 }
        private void MatchQueue(MatchState state)
        {
            MsmqBindingFilter lastMatch = state.LastMatch;
            int lastMatchLength         = state.LastMatchLength;

            foreach (MsmqBindingFilter filter2 in this.filters)
            {
                int num2 = filter2.Match(state.QueueName);
                if (num2 > lastMatchLength)
                {
                    lastMatchLength = num2;
                    lastMatch       = filter2;
                }
            }
            if (lastMatch != state.LastMatch)
            {
                if (state.LastMatch != null)
                {
                    state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
                }
                state.LastMatchLength = lastMatchLength;
                state.LastMatch       = lastMatch;
                state.CallbackState   = lastMatch.MatchFound(this.host, state.QueueName, state.IsPrivate);
            }
        }
 public bool ContainsFilter(MsmqBindingFilter filter)
 {
     lock (this.thisLock)
     {
         return(this.filters.Contains(filter));
     }
 }
 public void AddFilter(MsmqBindingFilter filter)
 {
     lock (this.thisLock)
     {
         this.filters.Add(filter);
         this.MatchFilter(filter, this.knownPublicQueues.Values);
         this.MatchFilter(filter, this.knownPrivateQueues.Values);
     }
 }
 public void AddFilter(MsmqBindingFilter filter)
 {
     lock (this.thisLock)
     {
         this.filters.Add(filter);
         this.MatchFilter(filter, this.knownPublicQueues.Values);
         this.MatchFilter(filter, this.knownPrivateQueues.Values);
     }
 }
 public void RemoveFilter(MsmqBindingFilter filter)
 {
     lock (this.thisLock)
     {
         this.filters.Remove(filter);
         this.RematchQueues(filter, this.knownPublicQueues.Values);
         this.RematchQueues(filter, this.knownPrivateQueues.Values);
     }
 }
        public void AddFilter(MsmqBindingFilter filter)
        {
            lock (this.thisLock)
            {
                this.filters.Add(filter);

                // Now - see if we match any known queues
                MatchFilter(filter, knownPublicQueues.Values);
                MatchFilter(filter, knownPrivateQueues.Values);
            }
        }
        public void AddFilter(MsmqBindingFilter filter)
        {
            lock (this.thisLock)
            {
                this.filters.Add(filter);

                // Now - see if we match any known queues
                MatchFilter(filter, knownPublicQueues.Values);
                MatchFilter(filter, knownPrivateQueues.Values);
            }
        }
 private void RematchQueues(MsmqBindingFilter filter, IEnumerable <MatchState> queues)
 {
     foreach (MatchState state in queues)
     {
         if (state.LastMatch == filter)
         {
             state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
             state.LastMatch       = null;
             state.LastMatchLength = -1;
             this.MatchQueue(state);
         }
     }
 }
 void RematchQueues(MsmqBindingFilter filter, IEnumerable <MatchState> queues)
 {
     // if any queue currently matches "filter", re-match it against the other filters:
     foreach (MatchState state in queues)
     {
         if (state.LastMatch == filter)
         {
             state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
             state.LastMatch       = null;
             state.LastMatchLength = -1;
             MatchQueue(state);
         }
     }
 }
 private void MatchFilter(MsmqBindingFilter filter, IEnumerable <MatchState> queues)
 {
     foreach (MatchState state in queues)
     {
         int num = filter.Match(state.QueueName);
         if (num > state.LastMatchLength)
         {
             if (state.LastMatch != null)
             {
                 state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
             }
             state.LastMatchLength = num;
             state.LastMatch       = filter;
             state.CallbackState   = filter.MatchFound(this.host, state.QueueName, state.IsPrivate);
         }
     }
 }
 private void MatchFilter(MsmqBindingFilter filter, IEnumerable<MatchState> queues)
 {
     foreach (MatchState state in queues)
     {
         int num = filter.Match(state.QueueName);
         if (num > state.LastMatchLength)
         {
             if (state.LastMatch != null)
             {
                 state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
             }
             state.LastMatchLength = num;
             state.LastMatch = filter;
             state.CallbackState = filter.MatchFound(this.host, state.QueueName, state.IsPrivate);
         }
     }
 }
        void MatchFilter(MsmqBindingFilter filter, IEnumerable <MatchState> queues)
        {
            // Run through all the queues - see if we are better than any existing matches...
            foreach (MatchState state in queues)
            {
                int matchLength = filter.Match(state.QueueName);
                if (matchLength > state.LastMatchLength)
                {
                    if (state.LastMatch != null)
                    {
                        state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
                    }

                    state.LastMatchLength = matchLength;
                    state.LastMatch       = filter;

                    state.CallbackState = filter.MatchFound(this.host, state.QueueName, state.IsPrivate);
                }
            }
        }
        public void RemoveFilter(MsmqBindingFilter filter)
        {
            lock (this.thisLock)
            {
                this.filters.Remove(filter);

                RematchQueues(filter, knownPublicQueues.Values);
                RematchQueues(filter, knownPrivateQueues.Values);
            }
        }
Ejemplo n.º 16
0
            public void RegisterBindingFilterIfNecessary(string host, MsmqBindingFilter filter)
            {
                lock (this.thisLock)
                {
                    MsmqBindingMonitor bindingMonitor;
                    if (!this.bindingMonitors.TryGetValue(host, out bindingMonitor))
                    {
                        bindingMonitor = new MsmqBindingMonitor(host);
                        bindingMonitor.Open();
                        this.bindingMonitors.Add(host, bindingMonitor);
                    }

                    // register the new filter if it doesn't already exist:
                    if (!bindingMonitor.ContainsFilter(filter))
                    {
                        bindingMonitor.AddFilter(filter);
                    }
                }
            }
Ejemplo n.º 17
0
 public void UnregisterBindingFilter(MsmqBindingFilter filter)
 {
     lock (this.thisLock)
     {
         foreach (MsmqBindingMonitor monitor in this.bindingMonitors.Values)
         {
             monitor.RemoveFilter(filter);
         }
     }
 }
 private void RematchQueues(MsmqBindingFilter filter, IEnumerable<MatchState> queues)
 {
     foreach (MatchState state in queues)
     {
         if (state.LastMatch == filter)
         {
             state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
             state.LastMatch = null;
             state.LastMatchLength = -1;
             this.MatchQueue(state);
         }
     }
 }
 void RematchQueues(MsmqBindingFilter filter, IEnumerable<MatchState> queues)
 {
     // if any queue currently matches "filter", re-match it against the other filters:
     foreach (MatchState state in queues)
     {
         if (state.LastMatch == filter)
         {
             state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
             state.LastMatch = null;
             state.LastMatchLength = -1;
             MatchQueue(state);
         }
     }
 }
        void MatchFilter(MsmqBindingFilter filter, IEnumerable<MatchState> queues)
        {
            // Run through all the queues - see if we are better than any existing matches...
            foreach (MatchState state in queues)
            {
                int matchLength = filter.Match(state.QueueName);
                if (matchLength > state.LastMatchLength)
                {
                    if (state.LastMatch != null)
                    {
                        state.LastMatch.MatchLost(this.host, state.QueueName, state.IsPrivate, state.CallbackState);
                    }

                    state.LastMatchLength = matchLength;
                    state.LastMatch = filter;

                    state.CallbackState = filter.MatchFound(this.host, state.QueueName, state.IsPrivate);
                }
            }
        }