Esempio n. 1
0
        internal HttpRoute(
            string routeTemplate,
            HttpRouteValueDictionary defaults,
            HttpRouteValueDictionary constraints,
            HttpRouteValueDictionary dataTokens,
            HttpMessageHandler handler,
            HttpParsedRoute parsedRoute
            )
        {
            _routeTemplate = routeTemplate == null ? String.Empty : routeTemplate;
            _defaults      = defaults ?? new HttpRouteValueDictionary();
            _constraints   = constraints ?? new HttpRouteValueDictionary();
            _dataTokens    = dataTokens ?? new HttpRouteValueDictionary();
            Handler        = handler;

            if (parsedRoute == null)
            {
                // The parser will throw for invalid routes.
                ParsedRoute = RouteParser.Parse(routeTemplate);
            }
            else
            {
                ParsedRoute = parsedRoute;
            }
        }
        // Default ordering goes through segments one by one and tries to apply an ordering
        private static int Compare(HttpRoute httpRoute1, HttpRoute httpRoute2)
        {
            HttpParsedRoute parsedRoute1 = httpRoute1.ParsedRoute;
            HttpParsedRoute parsedRoute2 = httpRoute2.ParsedRoute;

            IList <PathContentSegment> segments1 = parsedRoute1.PathSegments.OfType <PathContentSegment>().ToArray();
            IList <PathContentSegment> segments2 = parsedRoute2.PathSegments.OfType <PathContentSegment>().ToArray();

            for (int i = 0; i < segments1.Count && i < segments2.Count; i++)
            {
                PathContentSegment segment1 = segments1[i];
                PathContentSegment segment2 = segments2[i];

                int order1 = GetOrder(segment1, httpRoute1.Constraints);
                int order2 = GetOrder(segment2, httpRoute2.Constraints);

                if (order1 > order2)
                {
                    return(1);
                }
                else if (order1 < order2)
                {
                    return(-1);
                }
            }

            return(0);
        }
        public HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens)
        {
            _routeTemplate = String.IsNullOrWhiteSpace(routeTemplate) ? String.Empty : routeTemplate;
            _defaults      = defaults ?? new HttpRouteValueDictionary();
            _constraints   = constraints ?? new HttpRouteValueDictionary();
            _dataTokens    = dataTokens ?? new HttpRouteValueDictionary();

            // The parser will throw for invalid routes.
            _parsedRoute = HttpRouteParser.Parse(_routeTemplate);
        }
        public HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens)
        {
            _routeTemplate = String.IsNullOrWhiteSpace(routeTemplate) ? String.Empty : routeTemplate;
            _defaults = defaults ?? new HttpRouteValueDictionary();
            _constraints = constraints ?? new HttpRouteValueDictionary();
            _dataTokens = dataTokens ?? new HttpRouteValueDictionary();

            // The parser will throw for invalid routes. 
            _parsedRoute = HttpRouteParser.Parse(_routeTemplate);
        }
Esempio n. 5
0
        private static decimal GetPrecedence(string attributeRouteTemplate)
        {
            DefaultInlineConstraintResolver resolver    = new DefaultInlineConstraintResolver();
            HttpRouteValueDictionary        defaults    = new HttpRouteValueDictionary();
            HttpRouteValueDictionary        constraints = new HttpRouteValueDictionary();
            string standardRouteTemplate = InlineRouteTemplateParser.ParseRouteTemplate(attributeRouteTemplate,
                                                                                        defaults, constraints, new DefaultInlineConstraintResolver());
            HttpParsedRoute parsedRoute = HttpRouteParser.Parse(standardRouteTemplate);

            return(parsedRoute.GetPrecedence(constraints));
        }
Esempio n. 6
0
        internal HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens, HttpMessageHandler handler, HttpParsedRoute parsedRoute)
        {
            _routeTemplate = routeTemplate == null ? String.Empty : routeTemplate;
            _defaults = defaults ?? new HttpRouteValueDictionary();
            _constraints = constraints ?? new HttpRouteValueDictionary();
            _dataTokens = dataTokens ?? new HttpRouteValueDictionary();
            Handler = handler;

            if (parsedRoute == null)
            {
                // The parser will throw for invalid routes.
                ParsedRoute = RouteParser.Parse(routeTemplate);
            }
            else
            {
                ParsedRoute = parsedRoute;
            }
        }
Esempio n. 7
0
        internal HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens, HttpMessageHandler handler, HttpParsedRoute parsedRoute)
        {
            _routeTemplate = routeTemplate == null ? String.Empty : routeTemplate;
            _defaults      = defaults ?? new HttpRouteValueDictionary();
            _constraints   = constraints ?? new HttpRouteValueDictionary();
            _dataTokens    = dataTokens ?? new HttpRouteValueDictionary();
            Handler        = handler;

            if (parsedRoute == null)
            {
                // The parser will throw for invalid routes.
                ParsedRoute = RouteParser.Parse(routeTemplate);
            }
            else
            {
                ParsedRoute = parsedRoute;
            }

            System.Diagnostics.Trace.WriteLine(string.Format("RouteTemplate:{0},HttpMessageHandler:{1}", this.RouteTemplate, this.Handler));
        }
Esempio n. 8
0
        internal HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens, HttpMessageHandler handler, HttpParsedRoute parsedRoute)
        {
            _routeTemplate = routeTemplate == null ? String.Empty : routeTemplate;
            _defaults = defaults ?? new HttpRouteValueDictionary();
            _constraints = constraints ?? new HttpRouteValueDictionary();
            _dataTokens = dataTokens ?? new HttpRouteValueDictionary();
            Handler = handler;

            if (parsedRoute == null)
            {
                // The parser will throw for invalid routes.
                ParsedRoute = RouteParser.Parse(routeTemplate);
            }
            else
            {
                ParsedRoute = parsedRoute;
            }

            System.Diagnostics.Trace.WriteLine(string.Format("RouteTemplate:{0},HttpMessageHandler:{1}", this.RouteTemplate,this.Handler));

        }