Example #1
0
        private static string ResolveMethodSignatureWithParams(CodeGenerationParameter routeSignature)
        {
            var idParameter              = routeSignature.RetrieveRelatedValue(Label.RequireEntityLoading, x => bool.TrueString.ToLower() == x) ? string.Format(_methodParameterPattern, "String", "id") : string.Empty;
            var method                   = AggregateDetail.MethodWithName(routeSignature.Parent(), routeSignature.value);
            var dataClassname            = new TemplateStandard(TemplateStandardType.DataObject).ResolveClassname(routeSignature.Parent().value);
            var dataParameterDeclaration = string.Format(_methodParameterPattern, dataClassname, "data");
            var dataParameter            = method.HasAny(Label.MethodParameter) ? dataParameterDeclaration : "";
            var parameters               = string.Join(", ", new List <string>()
            {
                idParameter, dataParameter
            }.Where(param => param != string.Empty));

            return(string.Format(_methodSignaturePattern, routeSignature.value, parameters));
        }
        private AutoDispatchRouteTemplateData(CodeGenerationParameter route)
        {
            var aggregate = route.Parent(Label.Aggregate);

            _parameters =
                TemplateParameters.With(TemplateParameter.RetrievalRoute, IsRetrievalRoute(route))
                .And(TemplateParameter.IdType, StateFieldDetail.TypeOf(aggregate, "id"))
                .And(TemplateParameter.RouteMethod, route.RetrieveRelatedValue(Label.RouteMethod))
                .And(TemplateParameter.RoutePath, PathFormatter.FormatRelativeRoutePath(route))
                .And(TemplateParameter.DataObjectName, new TemplateStandard(TemplateStandardType.DataObject).ResolveClassname(aggregate.value))
                .And(TemplateParameter.RouteMappingValue, AutoDispatchMappingValueFormatter.Format(route.value))
                .And(TemplateParameter.RequireEntityLoading, route.RetrieveRelatedValue(Label.RequireEntityLoading, x => bool.TrueString.ToLower() == x))
                .And(TemplateParameter.AutoDispatchHandlersMappingName, new TemplateStandard(TemplateStandardType.AutoDispatchHandlersMapping).ResolveClassname(aggregate.value))
                .And(TemplateParameter.MethodName, route.value);
        }
Example #3
0
        public static string ResolveBodyType(CodeGenerationParameter route)
        {
            var httpMethod = route.RetrieveRelatedValue(Label.RouteMethod, Method.From);

            if (!_bodySupportedHttpMethods.Contains(httpMethod))
            {
                return(string.Empty);
            }

            if (route.Parent().IsLabeled(Label.Aggregate))
            {
                return(new TemplateStandard(TemplateStandardType.DataObject).ResolveClassname(route.Parent(Label.Aggregate).value));
            }

            return(route.RetrieveRelatedValue(Label.BodyType));
        }
Example #4
0
        private AutoDispatchHandlerEntryTemplateData(CodeGenerationParameter route)
        {
            var aggregate     = route.Parent(Label.Aggregate);
            var method        = AggregateDetail.MethodWithName(aggregate, route.value);
            var factoryMethod = method.RetrieveRelatedValue(Label.FactoryMethod, x => bool.TrueString.ToLower());

            //TODO: TemplateStandartType enum methods
            _parameters =
                TemplateParameters.With(TemplateParameter.MethodName, route.value)
                .And(TemplateParameter.FactoryMethod, factoryMethod)
                .And(TemplateParameter.AggregateProtocolName, aggregate.value)
                .And(TemplateParameter.DataObjectName, TemplateStandardType.DataObject)
                .And(TemplateParameter.AggregateProtocolVariable, Content.ClassFormatter.SimpleNameToAttribute(aggregate.value))
                .And(TemplateParameter.StateName, TemplateStandardType.AggregateState)
                .And(TemplateParameter.IndexName, AutoDispatchMappingValueFormatter.Format(route.value))
                .And(TemplateParameter.MethodInvocationParameters, ResolveMethodInvocationParameters(method));
        }