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("/")); }
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("/")); }
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("/")); } }
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("/")); } }
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()); } }
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("/")); } }
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(); } }
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()); } }
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); } }
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('^', '_')); } }
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('^', '_')); } }
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); }); }
protected override void visit(IRouteDefinition routeDefinition) { routeDefinition.Append(DiagnosticsUrls.ROOT); }
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(); } }
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("/")); }