//get the next filter that will match. public RoundRobinMessageFilter GetNext() { this.EnsureEnumerator(); RoundRobinMessageFilter next = (RoundRobinMessageFilter)this.currentPosition.Current; this.AdvanceEnumerator(); return(next); }
//add another filter to the internal message filter table internal void AddFilter(RoundRobinMessageFilter filter) { if (this.currentPosition != null) { throw new InvalidOperationException("Cannot add while enumerating"); } this.filters.Add(filter); filter.SetGroup(this); }
//when asked for a match, see if the enumerator is pointing at //this filter. If it is, return that this filter matched (true) //otherwise, return false public bool Match(RoundRobinMessageFilter filter) { this.EnsureEnumerator(); RoundRobinMessageFilter currentFilter = (RoundRobinMessageFilter)this.currentPosition.Current; bool matched = Object.ReferenceEquals(currentFilter, filter); if (matched) { this.AdvanceEnumerator(); } return(matched); }
//add a message filter to the MessageFilterTable public void Add(MessageFilter key, TFilterData value) { RoundRobinMessageFilter filter = (RoundRobinMessageFilter)key; RoundRobinGroup group; if (!this.groups.TryGetValue(filter.groupName, out group)) { group = new RoundRobinGroup(filter.groupName); this.groups.Add(filter.groupName, group); } group.AddFilter(filter); this.filters.Add(key, value); }
public bool GetMatchingValues(Message message, ICollection <TFilterData> results) { bool foundSome = false; foreach (RoundRobinGroup group in this.groups.Values) { RoundRobinMessageFilter matchingFilter = group.GetNext(); results.Add(this.filters[matchingFilter]); foundSome = true; } return(foundSome); }
//handle both the message and message buffer calls that can come into a MessageFilterTable public bool GetMatchingFilters(MessageBuffer messageBuffer, ICollection <MessageFilter> results) { bool foundSome = false; foreach (RoundRobinGroup group in this.groups.Values) { RoundRobinMessageFilter matchingFilter = group.GetNext(); results.Add(matchingFilter); foundSome = true; } return(foundSome); }