EndpointDispatcher LookupInCache(Message message, out bool addressMatched) { EndpointDispatcher result = null; int priority = int.MinValue; bool duplicatePriority = false; addressMatched = false; if (this.cachedEndpoints != null && this.cachedEndpoints.Count > 0) { for (int i = 0; i < this.cachedEndpoints.Count; i++) { EndpointDispatcher cachedEndpoint = cachedEndpoints[i]; int cachedPriority = cachedEndpoint.FilterPriority; MessageFilter cachedFilter = cachedEndpoint.EndpointFilter; bool matchResult; AndMessageFilter andFilter = cachedFilter as AndMessageFilter; if (andFilter != null) { bool addressResult; matchResult = andFilter.Match(message, out addressResult); addressMatched |= addressResult; } else { matchResult = cachedFilter.Match(message); } if (matchResult) { addressMatched = true; if (cachedPriority > priority || result == null) { result = cachedEndpoint; priority = cachedPriority; duplicatePriority = false; } else if (cachedPriority == priority && result != null) { duplicatePriority = true; } } } } if (duplicatePriority) { throw TraceUtility.ThrowHelperError(new MultipleFilterMatchesException(SR.GetString(SR.FilterMultipleMatches)), message); } return(result); }
private EndpointDispatcher LookupInCache(Message message, out bool addressMatched) { EndpointDispatcher dispatcher = null; int num = -2147483648; bool flag = false; addressMatched = false; if ((this.cachedEndpoints != null) && (this.cachedEndpoints.Count > 0)) { for (int i = 0; i < this.cachedEndpoints.Count; i++) { bool flag2; EndpointDispatcher dispatcher2 = this.cachedEndpoints[i]; int filterPriority = dispatcher2.FilterPriority; MessageFilter endpointFilter = dispatcher2.EndpointFilter; AndMessageFilter filter2 = endpointFilter as AndMessageFilter; if (filter2 != null) { bool flag3; flag2 = filter2.Match(message, out flag3); addressMatched |= flag3; } else { flag2 = endpointFilter.Match(message); } if (flag2) { addressMatched = true; if ((filterPriority > num) || (dispatcher == null)) { dispatcher = dispatcher2; num = filterPriority; flag = false; } else if ((filterPriority == num) && (dispatcher != null)) { flag = true; } } } } if (flag) { throw TraceUtility.ThrowHelperError(new MultipleFilterMatchesException(System.ServiceModel.SR.GetString("FilterMultipleMatches")), message); } return(dispatcher); }