System.ServiceModel.Discovery.FindCriteria.IsMatch C# (CSharp) Method

IsMatch() private method

private IsMatch ( EndpointDiscoveryMetadata endpointDiscoveryMetadata ) : bool
endpointDiscoveryMetadata EndpointDiscoveryMetadata
return bool
		public bool IsMatch (EndpointDiscoveryMetadata endpointDiscoveryMetadata)
		{
			var edm = endpointDiscoveryMetadata;
			if (edm == null)
				throw new ArgumentNullException ("endpointDiscoveryMetadata");
			if (ContractTypeNames.Count > 0) {
				bool match = false;
				foreach (var qn in ContractTypeNames)
					if (edm.ContractTypeNames.Contains (qn))
						match = true;
				if (!match)
					return false;
			}
			if (Scopes.Count > 0) {
				bool match = false;
				foreach (var scope in Scopes) {
					if (ScopeMatchBy == null || ScopeMatchBy.Equals (ScopeMatchByPrefix)) {
						if (edm.Scopes.Contains (scope))
							match = true;
					} else if (ScopeMatchBy.Equals (ScopeMatchByExact)) {
						if (edm.Scopes.Any (s => s.AbsoluteUri == scope.AbsoluteUri))
							match = true;
					}
					else if (ScopeMatchBy.Equals (ScopeMatchByUuid))
						throw new NotImplementedException ();
					else if (ScopeMatchBy.Equals (ScopeMatchByNone))
						throw new NotImplementedException ();
					else if (ScopeMatchBy.Equals (ScopeMatchByLdap))
						throw new NotImplementedException ();
					else
						throw new InvalidOperationException (String.Format ("Unexpected ScopeMatchBy value: {0}", ScopeMatchBy));
				}
				if (!match)
					return false;
			}
			if (Extensions.Count > 0)
				throw new NotImplementedException (String.Format ("{0} extensions are found", Extensions.Count));

			return true;
		}

Usage Example

        void Match(FindRequestContext findRequestContext)
        {
            FindCriteria criteria = findRequestContext.Criteria;

            if (!ScopeCompiler.IsSupportedMatchingRule(criteria.ScopeMatchBy))
            {
                return;
            }

            CompiledScopeCriteria[] compiledScopeCriterias = ScopeCompiler.CompileMatchCriteria(
                criteria.InternalScopes,
                criteria.ScopeMatchBy);

            int matchingEndpointCount = 0;

            for (int i = 0; i < this.publishedEndpoints.Count; i++)
            {
                if (criteria.IsMatch(this.publishedEndpoints[i], compiledScopeCriterias))
                {
                    findRequestContext.AddMatchingEndpoint(this.publishedEndpoints[i]);
                    matchingEndpointCount++;

                    if (matchingEndpointCount == criteria.MaxResults)
                    {
                        break;
                    }
                }
            }
        }
All Usage Examples Of System.ServiceModel.Discovery.FindCriteria::IsMatch