public TextBasedContent(TemplateStandard standard, TemplateFile templateFile, Type source, FileStream filer, string text) : base(standard) { this.text = text; _filer = filer; _source = source; file = templateFile.ToFile(); }
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)); }
private static void InferModelParameters(CodeGenerationParameter aggregateParameter, List <ContentBase> contents) { var modelActor = new TemplateStandard(TemplateStandardType.Aggregate).ResolveClassname(aggregateParameter.value); var modelProtocolQualifiedName = ContentQuery.FindFullyQualifiedClassName(new TemplateStandard(TemplateStandardType.AggregateProtocol), aggregateParameter.value, contents); var modelActorQualifiedName = ContentQuery.FindFullyQualifiedClassName(new TemplateStandard(TemplateStandardType.Aggregate), modelActor, contents); aggregateParameter.Relate(Label.ModelProtocol, modelProtocolQualifiedName).Relate(Label.ModelActor, modelActorQualifiedName); }
private string FindQueryMethodName(string aggregateName, List <TemplateData> queriesTemplateData) { if (queriesTemplateData == null || queriesTemplateData.Count == 0) { return(string.Empty); } string expectedQueriesName = new TemplateStandard(TemplateStandardType.Queries).ResolveClassname(aggregateName); return(queriesTemplateData.Select(x => x.Parameters()).Where(x => x.HasValue(TemplateParameter.QueriesName, expectedQueriesName)).Select(x => x.Find <string>(TemplateParameter.QueryAllMethodName)).First()); }
public static QueriesParameter From(CodeGenerationParameter aggregateParameter, List <ContentBase> contents, bool useCQRS) { if (!useCQRS) { return(QueriesParameter.Empty()); } var queriesProtocol = new TemplateStandard(TemplateStandardType.Queries).ResolveClassname(aggregateParameter.value); var queriesActor = new TemplateStandard(TemplateStandardType.QueriesActor).ResolveClassname(aggregateParameter.value); return(new QueriesParameter(ContentQuery.FindFullyQualifiedClassName(new TemplateStandard(TemplateStandardType.Queries), queriesProtocol, contents), ContentQuery.FindFullyQualifiedClassName(new TemplateStandard(TemplateStandardType.QueriesActor), queriesActor, contents))); }
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)); }
public void HandleDependencyOutcome(TemplateStandard standard, string outcome) => _parameters.Find <List <string> >(TemplateParameter.HandlerEntries).Add(outcome);
public static IEnumerable <ContentBase> FilterByStandard(TemplateStandard standard, List <ContentBase> contents) => contents.Where(content => content.Has(standard));
public static string FindPackage(TemplateStandard standard, string className, List <ContentBase> contents) => FilterByStandard(standard, contents).Where(content => content.RetrieveClassName() == className).Select(x => x.RetrievePackage()).FirstOrDefault() ?? string.Empty;
public static string FindPackage(TemplateStandard standard, List <ContentBase> contents) => FilterByStandard(standard, contents).Select(x => x.RetrievePackage()).FirstOrDefault() ?? string.Empty;
public static HashSet <string> FindFullyQualifiedClassNames(TemplateStandard standard, List <ContentBase> contents) => new HashSet <string>(FilterByStandard(standard, contents).Select(x => x.RetrieveQualifiedName()));
public CodeGenerationContext AddContent(TemplateStandard standard, TemplateFile file, string text) { _contents.Add(ContentBase.With(standard, file, _filer, _source, text)); return(this); }
//TODO: IsPresent will be added public static bool Exists(TemplateStandard standard, List <ContentBase> contents) => FilterByStandard(standard, contents).ToList().Any();
public TypeBasedContent(TemplateStandard standard, Type contentType) : base(standard) { this.contentType = contentType; }
public ProtocolBasedContent(TemplateStandard standard, Type contentProtocolType, Type contentType) : base(standard, contentType) { this.contentProtocolType = contentProtocolType; }
protected ContentBase(TemplateStandard standard) => this.standard = standard;
public CodeGenerationContext AddContent(TemplateStandard standard, Type protocolType, Type actorType) { _contents.Add(ContentBase.With(standard, protocolType, actorType)); return(this); }
public static HashSet <string> FindClassNames(TemplateStandard standard, string packageName, List <ContentBase> contents) => new HashSet <string>(FilterByStandard(standard, contents).Where(content => content.RetrievePackage() == packageName).Select(x => x.RetrieveClassName()));
public CodeGenerationContext AddContent(TemplateStandard standard, Type type) { _contents.Add(ContentBase.With(standard, type)); return(this); }
public static string FindFullyQualifiedClassName(TemplateStandard standard, string className, List <ContentBase> contents) => FindFullyQualifiedClassNames(standard, contents).Where(qualifiedClassName => qualifiedClassName.EndsWith(string.Concat(".", className))).FirstOrDefault() ?? throw new ArgumentException();