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 #2
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));
        }
Example #3
0
        public AutoDispatchHandlersMappingTemplateData(string basePackage, CodeGenerationParameter aggregate, List <TemplateData> queriesTemplateData, List <ContentBase> contents, bool useCQRS)
        {
            _aggregateName = aggregate.value;
            _parameters    =
                TemplateParameters.With(TemplateParameter.PackageName, ResolvePackage(basePackage))
                .And(TemplateParameter.AggregateProtocolName, _aggregateName)
                .And(TemplateParameter.StateName, new TemplateStandard().ResolveClassname(TemplateStandardType.AggregateState.ToString()))
                .And(TemplateParameter.DataObjectName, new TemplateStandard().ResolveClassname(TemplateStandardType.DataObject.ToString()))
                .And(TemplateParameter.QueriesName, new TemplateStandard().ResolveClassname(TemplateStandardType.Queries.ToString())).And(TemplateParameter.UseCqrs, useCQRS)
                .And(TemplateParameter.QueryAllMethodName, FindQueryMethodName(_aggregateName, queriesTemplateData))
                .AndResolve(TemplateParameter.QueryAllIndexName, @params => AutoDispatchMappingValueFormatter.Format(@params.Find <string>(TemplateParameter.QueryAllMethodName)))
                .And(TemplateParameter.AutoDispatchHandlersMappingName, Standard().ResolveClassname(_aggregateName))
                .And(TemplateParameter.HandlerIndexes, ResolveHandlerIndexes(aggregate, useCQRS))
                .And(TemplateParameter.HandlerEntries, new List <string>())
                .AddImports(ResolveImports(_aggregateName, contents));

            this.DependOn(AutoDispatchHandlerEntryTemplateData.From(aggregate).ToList());
        }
Example #4
0
        private List <string> ResolveHandlerIndexes(CodeGenerationParameter aggregate, bool useCQRS)
        {
            var handlers = new List <List <CodeGenerationParameter> >()
            {
                aggregate.RetrieveAllRelated(Label.RouteSignature).ToList(), new List <CodeGenerationParameter>()
                {
                    _stateAdapterHandler
                }
            }.SelectMany(x => x).ToList();

            return(Enumerable.Range(0, handlers.Count()).Select(index => string.Format(_handlerIndexPattern, AutoDispatchMappingValueFormatter.Format(handlers[index].value), index)).ToList());
        }