コード例 #1
0
        private TemplateContent GenerateContent(string database, string table, string className)
        {
            TemplateContent content = new TemplateContent();

            content.DatabaseName   = database;
            content.TableName      = table;
            content.ClassName      = className;
            content.PrimaryKeyName = _engine.GetPrimaryKeyColumn(database, table);
            List <ColumnItem> cols = GetTableFields(database, table, content.PrimaryKeyName);

            content.Columns = cols;
            return(content);
        }
コード例 #2
0
        public void Generate(string database, string table, string className, string rutaDestino, string rutaTemplate)
        {
            StreamReader sr       = new StreamReader(rutaTemplate);
            string       template = sr.ReadToEnd();

            sr.Close();
            TemplateContent content      = GenerateContent(database, table, className);
            string          renderedText = StringTemplate.Render(template, content);

            // Write the string array to a new file
            using (StreamWriter outputFile = new StreamWriter(rutaDestino))
            {
                outputFile.Write(renderedText);
            }
        }