static bool MatchScopes(EndpointDiscoveryMetadata endpointDiscoveryMetadata, CompiledScopeCriteria[] compiledScopeMatchCriterias, Uri scopeMatchBy)
        {
            if (compiledScopeMatchCriterias == null)
            {
                if (scopeMatchBy != FindCriteria.ScopeMatchByNone)
                {
                    return(true);
                }
                else
                {
                    // the criteria matches any service with no scopes defined
                    return(endpointDiscoveryMetadata.Scopes.Count == 0);
                }
            }

            if (scopeMatchBy == FindCriteria.ScopeMatchByNone)
            {
                // if scopeMatchBy is None, the Probe shouldn't have any Scopes defined
                return(false);
            }

            string[] compiledScopes;
            if (endpointDiscoveryMetadata.IsOpen)
            {
                compiledScopes = endpointDiscoveryMetadata.CompiledScopes;
            }
            else
            {
                compiledScopes = ScopeCompiler.Compile(endpointDiscoveryMetadata.Scopes);
            }

            if (compiledScopes == null)
            {
                // non-zero scopes in the criteria, but zero scopes in the metadata
                return(false);
            }

            for (int i = 0; i < compiledScopeMatchCriterias.Length; i++)
            {
                if (!ScopeCompiler.IsMatch(compiledScopeMatchCriterias[i], compiledScopes))
                {
                    return(false);
                }
            }

            return(true);
        }