Ejemplo n.º 1
0
        public void Save()
        {
            var dir = Path.Combine(_model.RootPath, _model.Project.Code, "src/Library/Infrastructure/Repositories/SqlServer");

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name}Repository.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Ejemplo n.º 2
0
        public void Save()
        {
            var dir = Path.Combine(_model.RootPath, _model.Project.Code,
                                   $"src/UI/{_model.Project.WebUIDicName}/src/api/components");

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name.FirstCharToLower()}.js");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Ejemplo n.º 3
0
        public void Save()
        {
            var dir = Path.Combine(_model.RootPath, "src/Web/Controllers");

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            if (_model.Module.ClassList != null && _model.Module.ClassList.Any())
            {
                foreach (var classModel in _model.Module.ClassList)
                {
                    _class = classModel;

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name}Controller.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Ejemplo n.º 4
0
        public void Save()
        {
            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, _model.Project.Code, "src/Library/Domain", _class.Name, "Models");
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    _propertyList = classModel.ModelPropertyList
                                    .Where(m => m.ModelType == ModelType.Query).ToList();

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name}QueryModel.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Ejemplo n.º 5
0
 private void SaveOutput(String filename)
 {
     /* "this" refers to the T4 TextTransformation instance that's producing the output.
      *  See https://msdn.microsoft.com/en-us/library/Microsoft.VisualStudio.TextTemplating.TextTransformation.aspx. */
     Directory.CreateDirectory(Path.GetDirectoryName(filename));
     File.Delete(filename);
     File.WriteAllText(filename, this.GenerationEnvironment.ToString());
     GenerationEnvironment.Clear();
 }
        public string Generate(string nameSpace, string className)
        {
            Namespace = nameSpace;
            ClassName = className;
            Effects   = _GenerateEffectsDictionary();

            GenerationEnvironment.Clear();

            return(TransformText());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Validates and then performs the variable replacements in the given template
        /// </summary>
        /// <returns>Evaluated template</returns>
        public string Print()
        {
            if (!Validate())
            {
                return(null);
            }

            GenerationEnvironment.Clear();
            return(TransformText());
        }
Ejemplo n.º 8
0
        private void SaveGeneratedCodeAsFile(string fileName)
        {
            string dir = Path.GetDirectoryName(Host.TemplateFile);

            string outputFilePath = Path.Combine(dir, fileName);

            File.WriteAllText(outputFilePath, GenerationEnvironment.ToString());

            GenerationEnvironment.Clear();
        }
Ejemplo n.º 9
0
        public void Save()
        {
            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, "src/Library/Domain", _class.Name);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    _baseEntityName = _class.BaseEntityType.ToDescription();
                    if (_baseEntityName.Contains("Guid"))
                    {
                        _baseEntityName = _baseEntityName.Replace("<Guid>", "");
                    }

                    if (_baseEntityName.Contains("SoftDelete"))
                    {
                        _baseEntityName = _baseEntityName.Replace(">", ", Guid>");
                    }

                    _propertyList = _class.PropertyList ?? new List <PropertyBuildModel>();

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, _class.Name + "Entity.cs");
                    File.WriteAllText(filePath, content);

                    #region ==处理枚举==

                    foreach (var property in classModel.PropertyList)
                    {
                        if (property.Type == PropertyType.Enum && property.Enum != null && !_hasCreadedEnumList.Contains(property.Enum.Id))
                        {
                            var enumHandler  = new EntityEnum(_model, classModel, property.Enum);
                            var enumContent  = enumHandler.TransformText();
                            var enumFilePath = Path.Combine(dir, property.Enum.Name + ".cs");
                            File.WriteAllText(enumFilePath, enumContent);
                        }
                    }

                    #endregion
                }
            }
        }
Ejemplo n.º 10
0
        public void Save()
        {
            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class      = classModel;
                    _properties = _class.PropertyList.Where(m => m.ShowInList).ToList();
                    var dir = Path.Combine(_model.RootPath, _model.Project.Code, $"src/UI/{_model.Project.WebUIDicName}/src/views", _class.Name.FirstCharToLower(), "index");
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"cols.js");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Ejemplo n.º 11
0
        public void Save()
        {
            if (_model.Module.ClassList != null && _model.Module.ClassList.Any())
            {
                foreach (var classModel in _model.Module.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, "src/Library/Application", _class.Name + "Service");
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name}Service.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }
        public void Save()
        {
            if (_model.Module.ClassList != null && _model.Module.ClassList.Any())
            {
                foreach (var classModel in _model.Module.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, $"src/UI/{_model.Module.WebUIDicName}/src/views", _class.Name.FirstCharToLower(), "index");
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, "index.vue");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Ejemplo n.º 13
0
        public void Save()
        {
            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, _model.Project.Code, "src/Library/Domain", _class.Name);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, _class.Name + "Entity.Extend.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }
 internal void Clear()
 {
     GenerationEnvironment.Clear();
 }
Ejemplo n.º 15
0
 public void Clear()
 {
     nodeDeclarations.Clear();
     nodeConnections.Clear();
     GenerationEnvironment.Clear();
 }