Exemplo n.º 1
0
        private string ResolveCommandMethodInvocation(CodeGenerationParameter aggregateParameter, CodeGenerationParameter routeParameter)
        {
            var argumentsFormat            = new AggregateArgumentsFormat.MethodInvocation("stage()", "data");
            var method                     = AggregateDetail.MethodWithName(aggregateParameter, routeParameter.value);
            var factoryMethod              = method.RetrieveRelatedValue(Label.FactoryMethod, x => bool.TrueString.ToLower() == x);
            var scope                      = factoryMethod ? MethodScopeType.Static : MethodScopeType.Instance;
            var methodInvocationParameters = argumentsFormat.Format(method, scope);
            var invoker                    = factoryMethod ? aggregateParameter.value : ClassFormatter.SimpleNameToAttribute(aggregateParameter.value);

            return(string.Format(_commandPattern, invoker, method.value, methodInvocationParameters));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
 public static bool requireModelFactory(CodeGenerationParameter aggregateParameter) => aggregateParameter.RetrieveAllRelated(Label.RouteSignature).Select(methodSignature => AggregateDetail.MethodWithName(aggregateParameter, methodSignature.value)).Any(method => method.RetrieveRelatedValue(Label.FactoryMethod, x => bool.TrueString.ToLower() == x));