Exemplo n.º 1
0
 public static void Load(
     RouteDefinition route,
     XmlNode defaultsNode)
 {
     foreach (XmlNode node in defaultsNode.ChildNodes)
     {
         if (node.Name == "add")
         {
             if (
                 (node.Attributes["parameterName"] != null) &&
                 (node.Attributes["defaultValue"] != null)
                 )
             {
                 RouteDefault d = new RouteDefault();
                 d.parameterName = node.Attributes["parameterName"].Value;
                 d.defaultValue  = node.Attributes["defaultValue"].Value;
                 route.RouteDefaults.Add(d);
             }
         }
     }
 }
Exemplo n.º 2
0
 public static void Load(
     RouteDefinition route,
     XmlNode defaultsNode)
 {
     foreach (XmlNode node in defaultsNode.ChildNodes)
     {
         if (node.Name == "add")
         {
             if (
                 (node.Attributes["parameterName"] != null) &&
                 (node.Attributes["restriction"] != null)
                 )
             {
                 RouteRestriction r = new RouteRestriction();
                 r.parameterName = node.Attributes["parameterName"].Value;
                 r.restriction   = node.Attributes["restriction"].Value;
                 route.RouteRestrictions.Add(r);
             }
         }
     }
 }
Exemplo n.º 3
0
        public static void Load(
            RouteDefinition route,
            XmlNode defaultsNode)
        {
            foreach (XmlNode node in defaultsNode.ChildNodes)
            {
                if (node.Name == "add")
                {
                    if (
                        (node.Attributes["parameterName"] != null)
                        && (node.Attributes["defaultValue"] != null)
                        )
                    {
                        RouteDefault d = new RouteDefault();
                        d.parameterName = node.Attributes["parameterName"].Value;
                        d.defaultValue = node.Attributes["defaultValue"].Value;
                        route.RouteDefaults.Add(d);
                    }

                }

            }
        }
Exemplo n.º 4
0
        public static void Load(
            RouteDefinition route,
            XmlNode defaultsNode)
        {
            foreach (XmlNode node in defaultsNode.ChildNodes)
            {
                if (node.Name == "add")
                {
                    if (
                        (node.Attributes["parameterName"] != null)
                        && (node.Attributes["restriction"] != null)
                        )
                    {
                        RouteRestriction r = new RouteRestriction();
                        r.parameterName = node.Attributes["parameterName"].Value;
                        r.restriction = node.Attributes["restriction"].Value;
                        route.RouteRestrictions.Add(r);
                    }

                }

            }
        }
Exemplo n.º 5
0
        public static Route GetRouteForElement(RouteDefinition route)
        {
            IRouteHandler        handler;
            RouteValueDictionary defaults     = new RouteValueDictionary();
            RouteValueDictionary restrictions = new RouteValueDictionary();

            if (String.IsNullOrEmpty(route.VirtualPath))
            {
                if (route.RouteHandler == null)
                {
                    //Stop Route ...
                    handler = new StopRoutingHandler();
                }
                else
                {
                    handler = route.RouteHandler;
                }
            }
            else
            {
                handler = new mojoPortal.RouteHelpers.RoutingHandler(route.VirtualPath);
            }

            foreach (RouteDefault d in route.RouteDefaults)
            {
                defaults.Add(d.ParameterName, d.DefaultValue);
            }


            foreach (RouteRestriction r in route.RouteRestrictions)
            {
                restrictions.Add(r.ParameterName, r.Restriction);
            }

            return(new Route(route.RouteUrl,
                             defaults, restrictions, handler));
        }
Exemplo n.º 6
0
        public static Route GetRouteForElement(RouteDefinition route)
        {
            IRouteHandler handler;
            RouteValueDictionary defaults = new RouteValueDictionary();
            RouteValueDictionary restrictions = new RouteValueDictionary();

            if (String.IsNullOrEmpty(route.VirtualPath))
            {
                if (route.RouteHandler == null)
                {
                    //Stop Route ...
                    handler = new StopRoutingHandler();
                }
                else
                {
                    handler = route.RouteHandler;
                }
            }
            else
            {
                handler = new mojoPortal.RouteHelpers.RoutingHandler(route.VirtualPath);
            }

            foreach (RouteDefault d in route.RouteDefaults)
            {
                defaults.Add(d.ParameterName, d.DefaultValue);
            }

            foreach (RouteRestriction r in route.RouteRestrictions)
            {
                restrictions.Add(r.ParameterName, r.Restriction);
            }

            return new Route(route.RouteUrl,
                defaults, restrictions, handler);
        }
Exemplo n.º 7
0
        public static void LoadRoutes(
            RoutingConfiguration config,
            XmlNode documentElement)
        {
            if (HttpContext.Current == null) return;
            if (documentElement.Name != "Routes") return;

            foreach (XmlNode node in documentElement.ChildNodes)
            {
                if (node.Name == "Route")
                {
                    RouteDefinition routeDef = new RouteDefinition();

                    XmlAttributeCollection attributeCollection
                        = node.Attributes;

                    if (attributeCollection["name"] != null)
                    {
                        routeDef.name = attributeCollection["name"].Value;
                    }

                    if (attributeCollection["routeUrl"] != null)
                    {
                        routeDef.routeUrl = attributeCollection["routeUrl"].Value;
                    }

                    if (attributeCollection["virtualPath"] != null)
                    {
                        routeDef.virtualPath = attributeCollection["virtualPath"].Value;
                    }

                    if (attributeCollection["routeHandler"] != null && typeof(IRouteHandler).IsAssignableFrom(Type.GetType(attributeCollection["routeHandler"].Value)))
                    {
                        routeDef.routeHandler = Activator.CreateInstance(Type.GetType(attributeCollection["routeHandler"].Value)) as IRouteHandler;
                    }

                    foreach (XmlNode child in node.ChildNodes)
                    {
                        if (child.Name == "Defaults")
                        {
                            RouteDefault.Load(
                                routeDef,
                                child);
                        }

                        if (child.Name == "Restrictions")
                        {
                            RouteRestriction.Load(
                                routeDef,
                                child);
                        }
                    }

                    config.RouteDefinitions.Add(routeDef);

                }

            }
        }
Exemplo n.º 8
0
        public static void LoadRoutes(
            RoutingConfiguration config,
            XmlNode documentElement)
        {
            if (HttpContext.Current == null)
            {
                return;
            }
            if (documentElement.Name != "Routes")
            {
                return;
            }

            foreach (XmlNode node in documentElement.ChildNodes)
            {
                if (node.Name == "Route")
                {
                    RouteDefinition routeDef = new RouteDefinition();

                    XmlAttributeCollection attributeCollection
                        = node.Attributes;

                    if (attributeCollection["name"] != null)
                    {
                        routeDef.name = attributeCollection["name"].Value;
                    }

                    if (attributeCollection["routeUrl"] != null)
                    {
                        routeDef.routeUrl = attributeCollection["routeUrl"].Value;
                    }

                    if (attributeCollection["virtualPath"] != null)
                    {
                        routeDef.virtualPath = attributeCollection["virtualPath"].Value;
                    }

                    if (attributeCollection["routeHandler"] != null && typeof(IRouteHandler).IsAssignableFrom(Type.GetType(attributeCollection["routeHandler"].Value)))
                    {
                        routeDef.routeHandler = Activator.CreateInstance(Type.GetType(attributeCollection["routeHandler"].Value)) as IRouteHandler;
                    }


                    foreach (XmlNode child in node.ChildNodes)
                    {
                        if (child.Name == "Defaults")
                        {
                            RouteDefault.Load(
                                routeDef,
                                child);
                        }

                        if (child.Name == "Restrictions")
                        {
                            RouteRestriction.Load(
                                routeDef,
                                child);
                        }
                    }

                    config.RouteDefinitions.Add(routeDef);
                }
            }
        }