コード例 #1
0
 private RouteDeclarationParameter(int routeIndex, int numberOfRoutes, CodeGenerationParameter routeSignatureParameter)
 {
     _signature     = RouteDetail.ResolveMethodSignature(routeSignatureParameter);
     _handlerName   = ResolveHandlerName();
     _path          = PathFormatter.FormatAbsoluteRoutePath(routeSignatureParameter);
     _bodyType      = RouteDetail.ResolveBodyType(routeSignatureParameter);
     _builderMethod = routeSignatureParameter.RetrieveRelatedValue(Label.RouteMethod);
     _parameterTypes.AddRange(ResolveParameterTypes(routeSignatureParameter));
     _last = routeIndex == numberOfRoutes - 1;
 }
コード例 #2
0
        private List <string> ResolveParameterTypes(CodeGenerationParameter routeSignatureParameter)
        {
            var bodyParameterName = RouteDetail.ResolveBodyName(routeSignatureParameter);
            var parameters        = _signature.Substring(_signature.IndexOf("(") + 1, _signature.LastIndexOf(")"));

            if (parameters.Trim() == string.Empty)
            {
                return(new List <string>());
            }
            return(parameters.Split(',').Select(parameter => parameter.Replace("readonly", string.Empty).Trim()).Where(parameter => !parameter.EndsWith(string.Concat(" ", bodyParameterName)))
                   .Select(parameter => parameter.Substring(0, parameter.IndexOf(" "))).ToList());
        }
コード例 #3
0
        private RouteMethodTemplateData(CodeGenerationParameter mainParameter, CodeGenerationParameter routeSignatureParameter, TemplateParameters parentParameters)
        {
            var invocationResolver       = HandlerInvocationResolver.With(mainParameter);
            var routeHandlerInvocation   = invocationResolver.ResolveRouteHandlerInvocation(mainParameter, routeSignatureParameter);
            var adapterHandlerInvocation = invocationResolver.ResolveAdapterHandlerInvocation(mainParameter, routeSignatureParameter);

            _parameters = TemplateParameters.With(TemplateParameter.RouteSignature, RouteDetail.ResolveMethodSignature(routeSignatureParameter))
                          .And(TemplateParameter.ModelAttribute, ResolveModelAttributeName(mainParameter, Label.ModelProtocol))
                          .And(TemplateParameter.RouteMethod, routeSignatureParameter.RetrieveRelatedValue(Label.RouteMethod))
                          .And(TemplateParameter.RequireEntityLoading, ResolveEntityLoading(routeSignatureParameter))
                          .And(TemplateParameter.AdapterHandlerInvocation, adapterHandlerInvocation)
                          .And(TemplateParameter.RouteHandlerInvocation, routeHandlerInvocation)
                          .And(TemplateParameter.IdName, ResolveIdName(routeSignatureParameter));

            parentParameters.AddImports(ResolveImports(mainParameter, routeSignatureParameter));
        }