Ejemplo n.º 1
0
        private RouteModel GetRouteModelForRoute(ITabContext context, MvcRouteBase routeBase, Dictionary <int, List <RouteDataMessage> > routeMessages, Dictionary <int, Dictionary <int, List <ProcessConstraintMessage> > > constraintMessages)
        {
            var routeModel = new RouteModel();

            var routeMessage = SafeFirstOrDefault(routeMessages.GetValueOrDefault(routeBase.GetHashCode()));

            if (routeMessage != null)
            {
                routeModel.Duration = routeMessage.Duration;
                routeModel.IsMatch  = routeMessage.IsMatch;
            }

            var route = routeBase as MvcRoute;

            if (route != null)
            {
                routeModel.Area        = (route.DataTokens != null && route.DataTokens.ContainsKey("area")) ? route.DataTokens["area"].ToString() : null;
                routeModel.Url         = route.Url;
                routeModel.RouteData   = ProcessRouteData(route.Defaults, routeMessage);
                routeModel.Constraints = ProcessConstraints(context, route, constraintMessages);
                routeModel.DataTokens  = ProcessDataTokens(route.DataTokens);
            }
            else
            {
                routeModel.Url = routeBase.ToString();
            }

            var routeName = routeBase as IRouteNameMixin;

            if (routeName != null)
            {
                routeModel.Name = routeName.Name;
            }

            return(routeModel);
        }