GetFirstMatchWildCardHashKeys() public static méthode

public static GetFirstMatchWildCardHashKeys ( string pathPartsForMatching ) : IEnumerable
pathPartsForMatching string
Résultat IEnumerable
        public IRestPath GetRestPathForRequest(string httpMethod, string pathInfo)
        {
            var matchUsingPathParts = RestPath.GetPathPartsForMatching(pathInfo);

            List <RestPath> firstMatches;

            var yieldedHashMatches = RestPath.GetFirstMatchHashKeys(matchUsingPathParts);

            foreach (var potentialHashMatch in yieldedHashMatches)
            {
                if (!this.RestPathMap.TryGetValue(potentialHashMatch, out firstMatches))
                {
                    continue;
                }

                var bestScore = -1;
                foreach (var restPath in firstMatches)
                {
                    var score = restPath.MatchScore(httpMethod, matchUsingPathParts);
                    if (score > bestScore)
                    {
                        bestScore = score;
                    }
                }
                if (bestScore > 0)
                {
                    foreach (var restPath in firstMatches)
                    {
                        if (bestScore == restPath.MatchScore(httpMethod, matchUsingPathParts))
                        {
                            return(restPath);
                        }
                    }
                }
            }

            var yieldedWildcardMatches = RestPath.GetFirstMatchWildCardHashKeys(matchUsingPathParts);

            foreach (var potentialHashMatch in yieldedWildcardMatches)
            {
                if (!this.RestPathMap.TryGetValue(potentialHashMatch, out firstMatches))
                {
                    continue;
                }

                var bestScore = -1;
                foreach (var restPath in firstMatches)
                {
                    var score = restPath.MatchScore(httpMethod, matchUsingPathParts);
                    if (score > bestScore)
                    {
                        bestScore = score;
                    }
                }
                if (bestScore > 0)
                {
                    foreach (var restPath in firstMatches)
                    {
                        if (bestScore == restPath.MatchScore(httpMethod, matchUsingPathParts))
                        {
                            return(restPath);
                        }
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// Get Best Matching Route.
        /// </summary>
        /// <param name="httpMethod"></param>
        /// <param name="pathInfo"></param>
        /// <param name="httpReq">If not null, ensures any Route matches any [Route(Matches)]</param>
        /// <returns></returns>
        public RestPath GetRestPathForRequest(string httpMethod, string pathInfo, IHttpRequest httpReq)
        {
            var matchUsingPathParts = RestPath.GetPathPartsForMatching(pathInfo);

            List <RestPath> firstMatches;
            RestPath        bestMatch = null;

            var yieldedHashMatches = RestPath.GetFirstMatchHashKeys(matchUsingPathParts);

            foreach (var potentialHashMatch in yieldedHashMatches)
            {
                if (!this.RestPathMap.TryGetValue(potentialHashMatch, out firstMatches))
                {
                    continue;
                }

                var bestScore = -1;
                foreach (var restPath in firstMatches)
                {
                    var matchScore = 0;
                    //Handle [Route(Matches)]
                    if (httpReq != null)
                    {
                        var matchFn = restPath.GetRequestRule();
                        if (matchFn != null)
                        {
                            var validRoute = matchFn(httpReq);
                            if (!validRoute)
                            {
                                continue;
                            }

                            matchScore = 1;
                        }
                    }

                    var score = restPath.MatchScore(httpMethod, matchUsingPathParts) + matchScore;
                    if (score > bestScore)
                    {
                        bestScore = score;
                        bestMatch = restPath;
                    }
                }
                if (bestScore > 0)
                {
                    return(bestMatch);
                }
            }

            var yieldedWildcardMatches = RestPath.GetFirstMatchWildCardHashKeys(matchUsingPathParts);

            foreach (var potentialHashMatch in yieldedWildcardMatches)
            {
                if (!this.RestPathMap.TryGetValue(potentialHashMatch, out firstMatches))
                {
                    continue;
                }

                var bestScore = -1;
                foreach (var restPath in firstMatches)
                {
                    var score = restPath.MatchScore(httpMethod, matchUsingPathParts);
                    if (score > bestScore)
                    {
                        bestScore = score;
                        bestMatch = restPath;
                    }
                }
                if (bestScore > 0)
                {
                    return(bestMatch);
                }
            }

            return(null);
        }