예제 #1
0
 public int MatchOther(ASplit other)
 {
     return
         _segments.Count(other.HasSegment);
 }
예제 #2
0
        private SingleRoute find_route(string path)
        {
            var split = new ASplit(path);
            int bestMatch = -1;
            SingleRoute bestRoute = null;

            foreach (var route in _routes.Values)
            {
                int hasToBeThereSegments = route.Split.Segments.Length;
                int match = split.MatchOther(route.Split);

                if (match >= hasToBeThereSegments)      // can happen if url has same segments,
                                                        // fe: /trading/affiliate/35273/user/get/trading/options
                if (match > bestMatch)
                {
                    bestMatch = match;
                    bestRoute = route;
                }
            }

            return bestRoute;
        }