Ejemplo n.º 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;
 }
        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));
        }