Exemplo n.º 1
0
        public static void Alter(IRouteDefinition route, string methodName, IEnumerable<string> properties, Action<string> log)
        {
            log("Method name interpreted by the MethodToUrlBuilder");
            var parts = methodName.Split('_').ToList();

            var method = parts.First().ToUpper();
            if (RouteDefinition.VERBS.Contains(method))
            {
                log(" - adding Http method constraint {0}".ToFormat(method));
                route.AddHttpMethodConstraint(method);
                parts.RemoveAt(0);
            }

            for (int i = 0; i < parts.Count; i++)
            {
                var part = parts[i];
                if (properties.Contains(part))
                {
                    log(" - adding route input for property " + part);
                    parts[i] = "{" + part + "}";
                }
                else
                {
                    parts[i] = part.ToLower();
                }

            }

            route.Append(parts.Join("/"));
        }
Exemplo n.º 2
0
        public static void Alter(IRouteDefinition route, string methodName, IEnumerable <string> properties, Action <string> log)
        {
            log("Method name interpreted by the MethodToUrlBuilder");
            var parts = methodName.Split('_').ToList();

            var method = parts.First().ToUpper();

            if (RouteDefinition.VERBS.Contains(method))
            {
                log(" - adding Http method constraint {0}".ToFormat(method));
                route.AddHttpMethodConstraint(method);
                parts.RemoveAt(0);
            }

            for (int i = 0; i < parts.Count; i++)
            {
                var part = parts[i];
                if (properties.Contains(part))
                {
                    log(" - adding route input for property " + part);
                    parts[i] = "{" + part + "}";
                }
                else
                {
                    parts[i] = part.ToLower();
                }
            }

            route.Append(parts.Join("/"));
        }
Exemplo n.º 3
0
        public static void Alter(IRouteDefinition route, string methodName, IEnumerable<string> properties,
            Action<string> log)
        {
            log("Method name interpreted by the MethodToUrlBuilder");
            var parts = AddHttpConstraints(route, methodName, log);

            for (var i = 0; i < parts.Count; i++)
            {
                var part = parts[i];
                if (properties.Contains(part))
                {
                    log(" - adding route input for property " + part);
                    parts[i] = "{" + part + "}";
                }
                else
                {
                    parts[i] = part.ToLower();
                }
            }

            if (parts.Any())
            {
                route.Append(parts.Join("/"));
            }
        }
Exemplo n.º 4
0
        public static void Alter(IRouteDefinition route, string methodName, IEnumerable <string> properties,
                                 Action <string> log)
        {
            log("Method name interpreted by the MethodToUrlBuilder");
            var parts = AddHttpConstraints(route, methodName, log);

            for (var i = 0; i < parts.Count; i++)
            {
                var part = parts[i];
                if (properties.Contains(part))
                {
                    log(" - adding route input for property " + part);
                    parts[i] = "{" + part + "}";
                }
                else
                {
                    parts[i] = part.ToLower();
                }
            }

            if (parts.Any())
            {
                route.Append(parts.Join("/"));
            }
        }
Exemplo n.º 5
0
        public void AddMethodName(IRouteDefinition route, ActionCall call)
        {
            if (_ignoredMethodNames.Contains(call.Method.Name.ToLower())) return;

            var urlPart = _methodNameBuilder.Build(call.Method);
            if (urlPart.IsNotEmpty())
            {
                route.Append(urlPart.ToLower());
            }
        }
Exemplo n.º 6
0
        private static void Append(IRouteDefinition route, IEnumerable <PropertyInfo> properties, params string[] parts)
        {
            var url = parts.Select(x => x.Split('_').Select(y => properties.Select(z => z.Name).Contains(y) ? "{" + y + "}" : y.ToLower()))
                      .Select(x => x.Where(y => !string.IsNullOrEmpty(y)).Join("/"))
                      .Where(x => !string.IsNullOrEmpty(x)).ToList();

            if (url.Any())
            {
                route.Append(url.Join("/"));
            }
        }
Exemplo n.º 7
0
        private void addNamespace(IRouteDefinition route, ActionCall call)
        {
            var ns = replace(call.HandlerType.Namespace, _ignoredNamespaces).TrimStart('.');

            ns = ns.Replace('.', '/');
            route.Append(ns);

            if (IgnoreControllerFolderName)
            {
                route.RemoveLastPatternPart();
            }
        }
Exemplo n.º 8
0
        private void addMethodName(IRouteDefinition route, ActionCall call)
        {
            if (_ignoredMethodNames.Contains(call.Method.Name.ToLower()))
            {
                return;
            }
            string urlPart = _methodNameBuilder.Build(call.Method);

            if (urlPart.IsNotEmpty())
            {
                route.Append(urlPart.ToLower());
            }
        }
Exemplo n.º 9
0
        private void addClassName(IRouteDefinition route, ActionCall call)
        {
            if (_ignoreClassNames.Contains(call.HandlerType))
            {
                return;
            }

            var className = getClassName(call);

            // So Home/HomeController == /home and not /home/home
            var lastName = route.Pattern.Split('/').LastOrDefault();

            if (className != lastName)
            {
                className += _appendClassBuilder.Build(call);
                route.Append(className);
            }
        }
Exemplo n.º 10
0
        public static void Alter(IRouteDefinition route, string methodName, IEnumerable<string> properties)
        {
            var parts = AddHttpConstraints(route, methodName);

            for (var i = 0; i < parts.Count; i++)
            {
                var part = parts[i];
                if (properties.Contains(part))
                {
                    parts[i] = "{" + part + "}";
                }
                else
                {
                    parts[i] = part.ToLower();
                }
            }

            if (parts.Any())
            {
                route.Append(parts.Join("/").Replace('^', '_'));
            }
        }
Exemplo n.º 11
0
        public static void Alter(IRouteDefinition route, string methodName, IEnumerable <string> properties)
        {
            var parts = AddHttpConstraints(route, methodName);

            for (var i = 0; i < parts.Count; i++)
            {
                var part = parts[i];
                if (properties.Contains(part))
                {
                    parts[i] = "{" + part + "}";
                }
                else
                {
                    parts[i] = part.ToLower();
                }
            }

            if (parts.Any())
            {
                route.Append(parts.Join("/").Replace('^', '_'));
            }
        }
Exemplo n.º 12
0
        public static void AddResourcePathInputs(IRouteDefinition route)
        {
            route.Append(UrlSuffix);


            route.RegisterRouteCustomization(r =>
            {
                if (r.Defaults == null)
                {
                    r.Defaults = new RouteValueDictionary();
                }

                r.Defaults.Add("Part0", null);
                r.Defaults.Add("Part1", null);
                r.Defaults.Add("Part2", null);
                r.Defaults.Add("Part3", null);
                r.Defaults.Add("Part4", null);
                r.Defaults.Add("Part5", null);
                r.Defaults.Add("Part6", null);
                r.Defaults.Add("Part7", null);
                r.Defaults.Add("Part8", null);
                r.Defaults.Add("Part9", null);
            });
        }
Exemplo n.º 13
0
        public static void AddResourcePathInputs(IRouteDefinition route)
        {
            route.Append(UrlSuffix);


            route.RegisterRouteCustomization(r =>
            {
                if (r.Defaults == null)
                {
                    r.Defaults = new RouteValueDictionary();
                }

                r.Defaults.Add("Part0", null);
                r.Defaults.Add("Part1", null);
                r.Defaults.Add("Part2", null);
                r.Defaults.Add("Part3", null);
                r.Defaults.Add("Part4", null);
                r.Defaults.Add("Part5", null);
                r.Defaults.Add("Part6", null);
                r.Defaults.Add("Part7", null);
                r.Defaults.Add("Part8", null);
                r.Defaults.Add("Part9", null);
            });
        }
Exemplo n.º 14
0
 protected override void visit(IRouteDefinition routeDefinition)
 {
     routeDefinition.Append(DiagnosticsUrls.ROOT);
 }
Exemplo n.º 15
0
        private void addNamespace(IRouteDefinition route, ActionCall call)
        {
            string ns = replace(call.HandlerType.Namespace, _ignoredNamespaces).TrimStart('.');
            ns = ns.Replace('.', '/');
            route.Append(ns);

            if (IgnoreControllerFolderName)
            {
                route.RemoveLastPatternPart();
            }
        }
Exemplo n.º 16
0
        private void addClassName(IRouteDefinition route, ActionCall call)
        {
            if (_ignoreClassNames.Contains(call.HandlerType)) return;

            string className = getClassName(call);

            // So Home/HomeController == /home and not /home/home
            string lastName = route.Pattern.Split('/').LastOrDefault();
            if (className != lastName)
            {
                className += _appendClassBuilder.Build(call);
                route.Append(className);
            }
        }
 private static void Append(IRouteDefinition route, IEnumerable<PropertyInfo> properties, params string[] parts)
 {
     var url = parts.Select(x => x.Split('_').Select(y => properties.Select(z => z.Name).Contains(y) ? "{" + y + "}" : y.ToLower()))
         .Select(x => x.Where(y => !string.IsNullOrEmpty(y)).Join("/"))
         .Where(x => !string.IsNullOrEmpty(x)).ToList();
     if (url.Any()) route.Append(url.Join("/"));
 }
Exemplo n.º 18
0
 protected override void visit(IRouteDefinition routeDefinition)
 {
     routeDefinition.Append(DiagnosticsUrls.ROOT);
 }