Ejemplo n.º 1
0
        private string ResolveProjectPath(CodeGenerationContext context)
        {
            var appName      = context.ParameterOf <string>(Label.ApplicationName);
            var targetFolder = context.ParameterOf <string>(Label.TargetFolder);

            return(Path.Combine(targetFolder, appName));
        }
        private AutoDispatchResourceHandlerTemplateData(CodeGenerationContext context, CodeGenerationParameter autoDispatchParameter)
        {
            _restResourceName = ClassFormatter.SimpleNameOf(autoDispatchParameter.value);

            var queryStoreProviderParameters = TemplateParameters.With(TemplateParameter.StorageType, StorageType.StateStore).And(TemplateParameter.Model, ModelType.Query);
            var queryStoreProviderName       = new TemplateStandard(TemplateStandardType.StoreProvider).ResolveClassname(queryStoreProviderParameters);
            var aggregateProtocolClassName   = ClassFormatter.SimpleNameOf(autoDispatchParameter.RetrieveRelatedValue(Label.ModelProtocol));

            _parameters = TemplateParameters.With(TemplateParameter.PackageName, ClassFormatter.PackageOf(autoDispatchParameter.value))
                          .And(TemplateParameter.StateName, new TemplateStandard(TemplateStandardType.AggregateState).ResolveClassname(aggregateProtocolClassName))
                          .And(TemplateParameter.Queries, QueriesParameter.From(autoDispatchParameter))
                          .And(TemplateParameter.RestResourceName, Standard().ResolveClassname(_restResourceName))
                          .And(TemplateParameter.UriRoot, autoDispatchParameter.RetrieveRelatedValue(Label.UriRoot))
                          .And(TemplateParameter.RouteDeclarations, RouteDeclarationParameter.From(autoDispatchParameter))
                          .And(TemplateParameter.ModelProtocol, autoDispatchParameter.RetrieveRelatedValue(Label.ModelProtocol))
                          .And(TemplateParameter.ModelActor, autoDispatchParameter.RetrieveRelatedValue(Label.ModelActor))
                          .And(TemplateParameter.HandlersConfigName, autoDispatchParameter.RetrieveRelatedValue(Label.HandlersConfigName))
                          .And(TemplateParameter.StoreProviderName, queryStoreProviderName).And(TemplateParameter.RouteMethod, new List <string>())
                          .And(TemplateParameter.AutoDispatchMappingName, _restResourceName).And(TemplateParameter.UseAutoDispatch, true)
                          .And(TemplateParameter.DataObjectName, new TemplateStandard(TemplateStandardType.DataObject).ResolveClassname(aggregateProtocolClassName))
                          .And(TemplateParameter.UseCqrs, context.ParameterOf <bool>(Label.Cqrs, x => bool.TrueString.ToLower() == x))
                          .AddImports(ResolveImports(context, autoDispatchParameter, queryStoreProviderName));

            DependOn(RouteMethodTemplateData.From(autoDispatchParameter, _parameters));
        }
Ejemplo n.º 3
0
        public static string From(CodeGenerationContext context, TemplateData templateData)
        {
            var location = context.ParameterOf <CodeGenerationLocationType>(Label.GenerationLocation);

            if (CodeGenerationLocation.IsInternal(location))
            {
                throw new NotSupportedException("Unable to resolve internal file location");
            }

            return(new ExternalFileLocationResolver().Resolve(context, templateData));
        }
Ejemplo n.º 4
0
 public bool ShouldProcess(CodeGenerationContext context) => context.HasParameter(Label.UseAutoDispatch) && context.ParameterOf(Label.UseAutoDispatch, x => bool.TrueString.ToLower() == x);