Exemple #1
0
        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);
            }
        }