private void ExecuteTemplateRepository(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputRepositoryPartial(tableInfo, configContext); if (File.Exists(pathOutput)) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "repository.partial"); if (!File.Exists(pathTemplateClass)) { return; } var pathTemplateFilters = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "repository.filters.expression"); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var textTemplateFilters = Read.AllText(tableInfo, pathTemplateFilters, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateApiStart(TableInfo tableInfo, Context configContext) { if (!tableInfo.MakeApi) { return; } var pathOutput = PathOutput.PathOutputWebApiStart(configContext); if (File.Exists(pathOutput)) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiStart(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateAppBase(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputApp(tableInfo, configContext); if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "app"); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateAppClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateAppClass); var hasAudit = Audit.ExistsAuditFieldsDefault(infos); classBuilder = classBuilder.Replace("<#hasAudit#>", hasAudit ? "this.Audit(model, alvo);" : string.Empty); var pathTemplateAudit = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "app.audit"); var textTemplateAppAudit = Read.AllText(tableInfo, pathTemplateAudit, this._defineTemplateFolder); var classBuilderAudit = GenericTagsTransformer(tableInfo, configContext, textTemplateAppAudit); classBuilder = classBuilder.Replace("<#auditMethod#>", hasAudit ? classBuilderAudit : string.Empty); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateMapsBase(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputMaps(tableInfo, configContext); var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "maps"); var pathTemplateLength = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "maps.length"); var pathTemplateRequired = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "maps.required"); var pathTemplateMapper = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "maps.mapper"); var pathTemplateManyToMany = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "maps.manytomany"); var pathTemplateCompositeKey = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "maps.compositekey"); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var textTemplateLength = Read.AllText(tableInfo, pathTemplateLength, this._defineTemplateFolder); var textTemplateRequired = Read.AllText(tableInfo, pathTemplateRequired, this._defineTemplateFolder); var textTemplateMapper = Read.AllText(tableInfo, pathTemplateMapper, this._defineTemplateFolder); var textTemplateManyToMany = Read.AllText(tableInfo, pathTemplateManyToMany, this._defineTemplateFolder); var textTemplateCompositeKey = Read.AllText(tableInfo, pathTemplateCompositeKey, this._defineTemplateFolder); var classBuilderitemTemplateLength = string.Empty; var classBuilderitemTemplateRequired = string.Empty; var classBuilderitemplateMapper = string.Empty; var classBuilderitemplateMapperKey = string.Empty; var classBuilderitemplateManyToMany = string.Empty; var classBuilderitemplateCompositeKey = string.Empty; string classBuilder = MakeClassBuilderMapORM(tableInfo, configContext, infos, textTemplateClass, textTemplateLength, textTemplateRequired, textTemplateMapper, textTemplateManyToMany, textTemplateCompositeKey, ref classBuilderitemTemplateLength, ref classBuilderitemTemplateRequired, ref classBuilderitemplateMapper, ref classBuilderitemplateMapperKey, ref classBuilderitemplateManyToMany, ref classBuilderitemplateCompositeKey); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateApiTestsBasic(TableInfo tableInfo, Context configContext) { var pathOutput = PathOutput.PathOutputApiTest(tableInfo, configContext); if (File.Exists(pathOutput)) { return; } if (!tableInfo.MakeTest) { return; } if (!tableInfo.MakeApi) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiTest(tableInfo)); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); classBuilder = classBuilder.Replace("<#filterByModel#>", MakeKFilterByModel(tableInfo)); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateDtoSave(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputDtoSpecialized(tableInfo, configContext); if (File.Exists(pathOutput)) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "dto.save"); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateOrderByDomainExtension(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { if (tableInfo.CodeCustomImplemented) { return; } if (!tableInfo.MakeDomain) { return; } var pathOutput = PathOutput.PathOutputInfraOrderByDomainExtension(tableInfo, configContext); if (File.Exists(pathOutput)) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.EntityOrderByDomainExtension(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = base.GenericTagsTransformer(tableInfo, configContext, textTemplateClass); using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateAppTests(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputApplicationTest(tableInfo, configContext); if (!tableInfo.MakeTest) { return; } if (!tableInfo.MakeApp) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.AppTest(tableInfo)); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateModels(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputDomainModelsPartial(tableInfo, configContext); if (File.Exists(pathOutput)) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "models.partial"); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); classBuilder = classBuilder.Replace("<#WhereSingle#>", MakeKeysFromGet(tableInfo)); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateModelsBase(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { if (tableInfo.CodeCustomImplemented) { return; } var pathOutput = PathOutput.PathOutputDomainModels(tableInfo, configContext); var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "models"); if (!File.Exists(pathTemplateClass)) { return; } var pathTemplatePropertys = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "models.property"); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var textTemplatePropertys = Read.AllText(tableInfo, pathTemplatePropertys, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); var classBuilderPropertys = string.Empty; var classBuilderFilters = string.Empty; if (infos.IsAny()) { foreach (var item in infos) { if (item.IsKey == 1) { classBuilder = classBuilder. Replace("<#KeyName#>", item.PropertyName). Replace("<#KeyNameType#>", item.Type); var cast = item.Type == "string" ? ".ToString()" : string.Empty; classBuilder = classBuilder.Replace("<#toString()#>", cast); } var itempropert = textTemplatePropertys. Replace("<#type#>", item.Type). Replace("<#propertyName#>", item.PropertyName); classBuilderPropertys += string.Format("{0}{1}{2}", Tabs.TabModels(), itempropert, System.Environment.NewLine); } } classBuilder = classBuilder.Replace("<#property#>", classBuilderPropertys); classBuilder = classBuilder.Replace("<#filtersExpressions#>", classBuilderFilters); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateContainerPartial(TableInfo tableInfo, Context configContext) { var pathOutput = PathOutput.PathOutputContainerPartial(configContext); if (File.Exists(pathOutput) || tableInfo.CodeCustomImplemented) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "container.partial"); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateContainerPartial(TableInfo tableInfo, Context configContext) { if (!tableInfo.MakeApi) { return; } var pathOutput = PathOutput.PathOutputContainerPartialApi(configContext); if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented) { return; } if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarContainerClassPartialExistentes"]) == false) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ContainerPartial(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateApiTests(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputApiTest(tableInfo, configContext); if (!tableInfo.MakeTest) { return; } if (!tableInfo.MakeApi) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiTest(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var pathTemplateMoqValues = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiTestMoqValues(tableInfo)); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var TextTemplateMoqValues = Read.AllText(tableInfo, pathTemplateMoqValues, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); var classBuilderMoqValues = string.Empty; foreach (var item in infos) { if (item.IsKey == 1) { continue; } if (Audit.IsAuditField(item.PropertyName)) { continue; } var itemvalue = TextTemplateMoqValues. Replace("<#propertyName#>", item.PropertyName). Replace("<#length#>", item.Type == "string" ? item.Length : string.Empty). Replace("<#moqMethod#>", DefineMoqMethd(item.Type)); classBuilderMoqValues += string.Format("{0}{1}{2}", Tabs.TabSets(), itemvalue, System.Environment.NewLine); } classBuilder = classBuilder.Replace("<#moqValuesinsert#>", classBuilderMoqValues); using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateEntitysExt(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { if (tableInfo.CodeCustomImplemented) { return; } if (!tableInfo.MakeDomain) { return; } var pathOutput = PathOutput.PathOutputDomainEntitysExt(tableInfo, configContext); if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented) { return; } if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarModelPartialExistentes"]) == false) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.EntityExt(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var pathTemplatePropertys = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.EntityProperty(tableInfo)); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var textTemplatePropertys = Read.AllText(tableInfo, pathTemplatePropertys, this._defineTemplateFolder); var classBuilder = textTemplateClass; classBuilder = classBuilder.Replace("<#classBaseEntity#>", this.InheritEntityBase(infos)); classBuilder = classBuilder.Replace("<#ctorparametersRequired#>", this.ConstructorParametersRequired(infos)); classBuilder = classBuilder.Replace("<#ctorparametersRequiredBase#>", this.ConstructorParametersRequiredBase(infos)); classBuilder = classBuilder.Replace("<#parametersRequired#>", this.ParametersRequired(infos)); classBuilder = classBuilder.Replace("<#parametersRequiredToBase#>", this.ParametersRequiredToBase(infos)); classBuilder = classBuilder.Replace("<#property#>", base.BuilderPropertys(infos, textTemplatePropertys, configContext)); classBuilder = classBuilder.Replace("<#initParametersRequired#>", this.InitParametersRequired(infos)); classBuilder = classBuilder.Replace("<#methodsSeters#>", this.MethodsSeters(infos, tableInfo)); classBuilder = classBuilder.Replace("<#parametersRequiredConstruction#>", this.ParametersRequiredConstruction(infos)); classBuilder = classBuilder.Replace("<#methodsSetersConstruction#>", this.MethodsSetersConstruction(infos)); classBuilder = base.GenericTagsTransformer(tableInfo, configContext, classBuilder); using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateContainer(TableInfo tableInfo, Context configContext) { if (!tableInfo.MakeApi) { return; } var pathOutput = PathOutput.PathOutputContainerApi(configContext); var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.Container(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var pathTemplateInjections = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ContainerInjections(tableInfo)); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var TextTemplateInjections = Read.AllText(tableInfo, pathTemplateInjections, this._defineTemplateFolder); if (configContext.Module.IsNullOrEmpty()) { textTemplateClass = textTemplateClass.Replace("<#domainSource#>", configContext.ProjectName); } var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); var classBuilderMappers = string.Empty; foreach (var item in configContext.TableInfo) { if (!string.IsNullOrEmpty(item.ClassName)) { var itemInjections = TextTemplateInjections. Replace("<#namespace#>", configContext.Namespace). Replace("<#module#>", configContext.Module.IsNullOrEmpty() ? configContext.ProjectName : configContext.Module). Replace("<#className#>", item.ClassName). Replace("<#domainSource#>", configContext.DomainSource.IsNullOrEmpty() ? configContext.ProjectName : configContext.DomainSource). Replace("<#namespaceDomainSource#>", configContext.NamespaceDomainSource); classBuilderMappers += string.Format("{0}{1}", itemInjections, System.Environment.NewLine); } } classBuilder = classBuilder.Replace("<#injections#>", classBuilderMappers); using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateAutoMapperProfileBase(TableInfo tableInfo, Context configContext) { var pathOutput = PathOutput.PathOutputAutoMapperProfileBase(configContext, tableInfo); var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "profile"); if (!File.Exists(pathTemplateClass)) { return; } var pathTemplateMappers = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "profile.registers"); var pathTemplateMappersSave = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "profile.registers.save"); var pathTemplateMappersGet = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "profile.registers.get"); var pathTemplateMappersDetail = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "profile.registers.detail"); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var textTemplateMappers = Read.AllText(tableInfo, pathTemplateMappers, this._defineTemplateFolder); var textTemplateMappersSave = Read.AllText(tableInfo, pathTemplateMappersSave, this._defineTemplateFolder); var textTemplateMappersGet = Read.AllText(tableInfo, pathTemplateMappersGet, this._defineTemplateFolder); var textTemplateMappersDetail = Read.AllText(tableInfo, pathTemplateMappersDetail, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); var classBuilderMappers = string.Empty; foreach (var item in configContext.TableInfo) { var className = item.ClassName; if (!string.IsNullOrEmpty(className)) { var itemMapper = textTemplateMappers.Replace("<#className#>", className); var itemMapperSave = textTemplateMappersSave.Replace("<#className#>", className); var itemMapperGet = textTemplateMappersGet.Replace("<#className#>", className); var itemMapperDetail = textTemplateMappersDetail.Replace("<#className#>", className); classBuilderMappers += string.Format("{0}{1}{2}", Tabs.TabSets(), itemMapper, System.Environment.NewLine); classBuilderMappers += string.Format("{0}{1}{2}", Tabs.TabSets(), itemMapperSave, System.Environment.NewLine); classBuilderMappers += string.Format("{0}{1}{2}", Tabs.TabSets(), itemMapperGet, System.Environment.NewLine); classBuilderMappers += string.Format("{0}{1}{2}", Tabs.TabSets(), itemMapperDetail, System.Environment.NewLine); } } classBuilder = classBuilder.Replace("<#registers#>", classBuilderMappers); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateFilter(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { if (tableInfo.MovedBaseClassToShared) { return; } var pathOutput = PathOutput.PathOutputFilterWithFolder(tableInfo, configContext); var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.Filter(tableInfo)); var pathTemplatePropertys = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ModelsProperty(tableInfo)); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var TextTemplatePropertys = Read.AllText(tableInfo, pathTemplatePropertys, this._defineTemplateFolder); if (!File.Exists(pathTemplateClass)) { return; } var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); var classBuilderPropertys = string.Empty; if (infos.IsAny()) { foreach (var item in infos) { classBuilderPropertys = MakeFilterDateRange(TextTemplatePropertys, classBuilderPropertys, item); if (item.Type == "bool") { classBuilderPropertys = AddPropertyFilter(TextTemplatePropertys, classBuilderPropertys, item, item.PropertyName, "bool?"); } else { classBuilderPropertys = AddPropertyFilter(TextTemplatePropertys, classBuilderPropertys, item, item.PropertyName, item.Type); } } } classBuilder = classBuilder.Replace("<#property#>", classBuilderPropertys); using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateEntityMapBase(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { if (!tableInfo.MakeDomain) { return; } if (!tableInfo.Scaffold) { return; } var pathOutput = PathOutput.PathOutputEntityMapBase(tableInfo, configContext); var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.EntityMapBase(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var pathTemplateLength = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsLength(tableInfo)); var pathTemplateRequired = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsRequired(tableInfo)); var pathTemplateMapper = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsMapper(tableInfo)); var pathTemplateManyToMany = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsManyToMany(tableInfo)); var pathTemplateCompositeKey = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsCompositeKey(tableInfo)); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var textTemplateLength = Read.AllText(tableInfo, pathTemplateLength, this._defineTemplateFolder); var textTemplateRequired = Read.AllText(tableInfo, pathTemplateRequired, this._defineTemplateFolder); var textTemplateMapper = Read.AllText(tableInfo, pathTemplateMapper, this._defineTemplateFolder); var textTemplateManyToMany = Read.AllText(tableInfo, pathTemplateManyToMany, this._defineTemplateFolder); var textTemplateCompositeKey = Read.AllText(tableInfo, pathTemplateCompositeKey, this._defineTemplateFolder); var classBuilderitemTemplateLength = string.Empty; var classBuilderitemTemplateRequired = string.Empty; var classBuilderitemplateMapper = string.Empty; var classBuilderitemplateMapperKey = string.Empty; var classBuilderitemplateManyToMany = string.Empty; var classBuilderitemplateCompositeKey = string.Empty; string classBuilder = base.MakeClassBuilderMapORM(tableInfo, configContext, infos, textTemplateClass, textTemplateLength, textTemplateRequired, textTemplateMapper, textTemplateManyToMany, textTemplateCompositeKey, ref classBuilderitemTemplateLength, ref classBuilderitemTemplateRequired, ref classBuilderitemplateMapper, ref classBuilderitemplateMapperKey, ref classBuilderitemplateManyToMany, ref classBuilderitemplateCompositeKey); using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateDbContext(TableInfo tableInfo, Context configContext) { if (!tableInfo.MakeDomain) { return; } var pathOutput = PathOutput.PathOutputDbContext(configContext); var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.Context(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var pathTemplateRegister = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ContextMappers(tableInfo)); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var TextTemplateMappers = Read.AllText(tableInfo, pathTemplateRegister, this._defineTemplateFolder); textTemplateClass = textTemplateClass.Replace("<#module#>", configContext.ContextName); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); var classBuilderMappers = string.Empty; foreach (var item in configContext.TableInfo.Where(_ => _.Scaffold)) { var itemMappaer = TextTemplateMappers. Replace("<#className#>", item.ClassName); classBuilderMappers += string.Format("{0}{1}{2}", Tabs.TabMaps(), itemMappaer, System.Environment.NewLine); } classBuilder = classBuilder.Replace("<#mappers#>", classBuilderMappers); using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateApiMore(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputApiMore(tableInfo, configContext); if (!tableInfo.MakeApi) { return; } if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented) { return; } if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarApiExistentes"]) == false) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiMore(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); if (!tableInfo.Authorize) { classBuilder = classBuilder.Replace("[Authorize]", string.Empty); } using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateApi(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputApi(tableInfo, configContext); if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "api"); var pathTemplateApiGet = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "api.get"); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var TextTemplateApiGet = Read.AllText(tableInfo, pathTemplateApiGet, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); var classBuilderApiGet = string.Empty; if (!tableInfo.IsCompositeKey && tableInfo.Keys.IsNotNull()) { classBuilderApiGet = TextTemplateApiGet; classBuilderApiGet = classBuilderApiGet.Replace("<#className#>", tableInfo.ClassName); classBuilderApiGet = classBuilderApiGet.Replace("<#KeyName#>", tableInfo.Keys.FirstOrDefault()); classBuilderApiGet = classBuilderApiGet.Replace("<#KeyType#>", tableInfo.KeysTypes.FirstOrDefault()); } classBuilder = classBuilder.Replace("<#ApiGet#>", classBuilderApiGet); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateAppTestsMoqPartial(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputApplicationTestMoqPartial(tableInfo, configContext); if (!tableInfo.MakeApp) { return; } if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented) { return; } if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarMoqClassPartialExistentes"]) == false) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.AppTestMoqPartial(tableInfo)); var pathTemplateReletedValues = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.AppTestReleted(tableInfo)); var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var TextTemplateReletedValues = Read.AllText(tableInfo, pathTemplateReletedValues, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); classBuilder = MakeReletedIntanceValues(tableInfo, configContext, TextTemplateReletedValues, classBuilder); var classBuilderMoqValues = string.Empty; using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }
private void ExecuteTemplateRepositoryBase(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { if (tableInfo.CodeCustomImplemented) { return; } var pathOutput = PathOutput.PathOutputRepository(tableInfo, configContext); var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "repository"); if (!File.Exists(pathTemplateClass)) { return; } var pathTemplateFilters = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), "repository.filters.expression"); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var textTemplateFilters = Read.AllText(tableInfo, pathTemplateFilters, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); var classBuilderFilters = string.Empty; if (infos.IsAny()) { foreach (var item in infos) { if (item.IsKey == 1) { classBuilder = classBuilder .Replace("<#KeyName#>", item.PropertyName) .Replace("<#KeyNameType#>", item.Type); var cast = item.Type == "string" ? ".ToString()" : string.Empty; classBuilder = classBuilder.Replace("<#toString()#>", cast); } var itemFilters = string.Empty; if (item.Type == "string") { itemFilters = textTemplateFilters.Replace("<#propertyName#>", item.PropertyName); itemFilters = itemFilters.Replace("<#condition#>", string.Format("_ => _.{0}.Contains(filters.{0})", item.PropertyName)); itemFilters = itemFilters.Replace("<#filtersRange#>", string.Empty); } else if (item.Type == "DateTime") { var itemFiltersStart = textTemplateFilters.Replace("<#propertyName#>", String.Format("{0}Start", item.PropertyName)); itemFiltersStart = itemFiltersStart.Replace("<#condition#>", string.Format("_ => _.{0} >= filters.{0}Start ", item.PropertyName)); itemFiltersStart = itemFiltersStart.Replace("<#filtersRange#>", string.Empty); var itemFiltersEnd = textTemplateFilters.Replace("<#propertyName#>", String.Format("{0}End", item.PropertyName)); itemFiltersEnd = itemFiltersEnd.Replace("<#condition#>", string.Format("_ => _.{0} <= filters.{0}End", item.PropertyName)); itemFiltersEnd = itemFiltersEnd.Replace("<#filtersRange#>", string.Format("filters.{0}End = filters.{0}End.AddDays(1).AddMilliseconds(-1);", item.PropertyName)); itemFilters = String.Format("{0}{1}{2}{3}{4}", itemFiltersStart, System.Environment.NewLine, Tabs.TabSets(), itemFiltersEnd, System.Environment.NewLine); } else if (item.Type == "DateTime?") { var itemFiltersStart = textTemplateFilters.Replace("<#propertyName#>", String.Format("{0}Start", item.PropertyName)); itemFiltersStart = itemFiltersStart.Replace("<#condition#>", string.Format("_ => _.{0} != null && _.{0}.Value >= filters.{0}Start.Value", item.PropertyName)); itemFiltersStart = itemFiltersStart.Replace("<#filtersRange#>", string.Empty); var itemFiltersEnd = textTemplateFilters.Replace("<#propertyName#>", String.Format("{0}End", item.PropertyName)); itemFiltersEnd = itemFiltersEnd.Replace("<#condition#>", string.Format("_ => _.{0} != null && _.{0}.Value <= filters.{0}End", item.PropertyName)); itemFiltersEnd = itemFiltersEnd.Replace("<#filtersRange#>", string.Format("filters.{0}End = filters.{0}End.Value.AddDays(1).AddMilliseconds(-1);", item.PropertyName)); itemFilters = String.Format("{0}{1}{2}{3}{4}", itemFiltersStart, System.Environment.NewLine, Tabs.TabSets(), itemFiltersEnd, System.Environment.NewLine); } else if (item.Type == "bool?") { itemFilters = textTemplateFilters.Replace("<#propertyName#>", item.PropertyName); itemFilters = itemFilters.Replace("<#condition#>", string.Format("_ => _.{0} != null && _.{0}.Value == filters.{0}", item.PropertyName)); itemFilters = itemFilters.Replace("<#filtersRange#>", string.Empty); } else if (item.Type == "int?" || item.Type == "Int64?" || item.Type == "Int16?" || item.Type == "decimal?" || item.Type == "float?") { itemFilters = textTemplateFilters.Replace("<#propertyName#>", item.PropertyName); itemFilters = itemFilters.Replace("<#condition#>", string.Format("_ => _.{0} != null && _.{0}.Value == filters.{0}", item.PropertyName)); itemFilters = itemFilters.Replace("<#filtersRange#>", string.Empty); } else { itemFilters = textTemplateFilters.Replace("<#propertyName#>", item.PropertyName); itemFilters = itemFilters.Replace("<#condition#>", string.Format("_ => _.{0} == filters.{0}", item.PropertyName)); itemFilters = itemFilters.Replace("<#filtersRange#>", string.Empty); } classBuilderFilters += string.Format("{0}{1}{2}", Tabs.TabSets(), itemFilters, System.Environment.NewLine); } } classBuilder = classBuilder.Replace("<#filtersExpressions#>", classBuilderFilters); using (var stream = new StreamWriter(pathOutput)) { stream.Write(classBuilder); } }
private void ExecuteTemplateApi(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos) { var pathOutput = PathOutput.PathOutputApi(tableInfo, configContext); if (!tableInfo.MakeApi) { return; } if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented) { return; } if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarApiExistentes"]) == false) { return; } var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiBase(tableInfo)); var pathTemplateApiGet = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiGet(tableInfo)); if (!File.Exists(pathTemplateClass)) { return; } var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder); var TextTemplateApiGet = Read.AllText(tableInfo, pathTemplateApiGet, this._defineTemplateFolder); var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass); var classBuilderApiGet = string.Empty; if (!tableInfo.IsCompositeKey && tableInfo.Keys.IsAny()) { classBuilderApiGet = TextTemplateApiGet; classBuilderApiGet = classBuilderApiGet.Replace("<#className#>", tableInfo.ClassName); classBuilderApiGet = classBuilderApiGet.Replace("<#namespace#>", configContext.Namespace); classBuilderApiGet = classBuilderApiGet.Replace("<#inheritClassName#>", tableInfo.InheritClassName); classBuilderApiGet = classBuilderApiGet.Replace("<#KeyName#>", tableInfo.Keys.FirstOrDefault()); classBuilderApiGet = classBuilderApiGet.Replace("<#KeyType#>", tableInfo.KeysTypes.FirstOrDefault()); } classBuilder = classBuilder.Replace("<#ApiGet#>", classBuilderApiGet); var pathTemplateCustoMethod = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiCustomMethod(tableInfo)); classBuilder = this.CustomMethods(tableInfo, configContext, classBuilder, pathTemplateCustoMethod); if (!tableInfo.Authorize) { classBuilder = classBuilder.Replace("[Authorize]", string.Empty); } using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); } }