// TODO -- sucks, but need to break the IUrlPolicy signature to add diagnostics public IRouteDefinition Build(ActionCall call) { var route = call.ToRouteDefinition(); // TODO -- far better diagnostics here if (MethodToUrlBuilder.Matches(call.Method.Name)) { MethodToUrlBuilder.Alter(route, call); return(route); } if (!IgnoreControllerNamespaceEntirely) { addNamespace(route, call); } if (!IgnoreControllerNamesEntirely) { addClassName(route, call); } AddMethodName(route, call); if (call.HasInput) { _routeInputPolicy.AlterRoute(route, call); } _modifications.Where(m => m.Filter(call)).Each(m => m.Modify(route)); return(route); }
public virtual IRouteDefinition Build(ActionCall call) { var routeDefinition = call.ToRouteDefinition(); var strippedNamespace = stripNamespace(call); visit(routeDefinition); if (strippedNamespace != call.HandlerType.Namespace) { if (!strippedNamespace.Contains(".")) { routeDefinition.Append(breakUpCamelCaseWithHypen(strippedNamespace)); } else { var patternParts = strippedNamespace.Split(new[] { "." }, StringSplitOptions.None); foreach (var patternPart in patternParts) { routeDefinition.Append(breakUpCamelCaseWithHypen(patternPart.Trim())); } } } var handlerName = call.HandlerType.Name; var match = HandlerExpression.Match(handlerName); if (match.Success && MethodToUrlBuilder.Matches(handlerName)) { // We're forcing handlers to end with "_handler" in this case handlerName = handlerName.Substring(0, match.Index); var properties = call.HasInput ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys : new string[0]; MethodToUrlBuilder.Alter(routeDefinition, handlerName, properties, text => { }); } else { // Otherwise we're expecting something like "GetHandler" var httpMethod = call.HandlerType.Name.Replace(HANDLER, string.Empty); routeDefinition.ConstrainToHttpMethods(httpMethod.ToUpper()); } if (call.HasInput) { routeDefinition.ApplyInputType(call.InputType()); } return(routeDefinition); }