public static RegexRoute MapRegexRoute(this RouteCollection routes, string name, string url, string pattern, object defaults, object constraints, string[] namespaces)
        {
            if (routes == null)
            {
                throw new ArgumentNullException("routes");
            }

            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }

            var route = new RegexRoute(url, pattern, constraints, new MvcRouteHandler())
            {
                DataTokens = new RouteValueDictionary(),
                Defaults = new RouteValueDictionary(defaults)
            };

            if (namespaces != null && namespaces.Length > 0)
            {
                route.DataTokens["Namespaces"] = namespaces;
            }

            routes.Add(name, route);

            return route;
        }
        public static RegexRoute MapRegexRoute(this RouteCollection routes, string name, string url, string pattern, object defaults, object constraints, string[] namespaces, IRouteHandler routeHandler)
        {
            if (routes == null)
            {
                throw new ArgumentNullException("routes");
            }

            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }

            var route = new RegexRoute(url, pattern, constraints, routeHandler)
            {
                Defaults   = new RouteValueDictionary(defaults),
                DataTokens = new RouteValueDictionary()
            };

            if (route.Defaults.ContainsKey("Area"))
            {
                route.DataTokens["Area"] = route.Defaults["Area"];
            }

            if (namespaces != null && namespaces.Length > 0)
            {
                route.DataTokens["Namespaces"] = namespaces;
            }

            routes.Add(name, route);

            return(route);
        }