Example #1
0
 /// <summary>
 /// Create a new instance of a template parser
 /// </summary>
 /// <param name="Template">The template to be parsed</param>
 /// <param name="Data">The Data to use in the template</param>
 /// <param name="Parent">The parent generator object</param>
 public TemplateParser(Template Template, TemplateData Data, Generator Parent)
 {
     _data = Data;
     _parent = Parent;
     _template = Template;
     _templateLines = _template.Content.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
 }
Example #2
0
        /// <summary>
        /// loads the templates found in the folder and subfolders
        /// </summary>
        /// <param name="folder"></param>
        void LoadTemplatesRecursively(string folder)
        {
            // parse template definition files in the folder
            string xmlFilePath = Path.Combine(folder, "templates.xml");
            if (File.Exists(xmlFilePath))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(xmlFilePath);
                foreach (XmlNode node in doc.DocumentElement.ChildNodes)
                {
                    string path = Path.Combine(folder, node.Attributes["file"].InnerText);
                    Template template = new Template(node.Attributes["name"].InnerText, File.ReadAllText(path), path, node.Attributes["for"].InnerText, false);
                    _templates.Add(template);
                }
            }

            // run on each subfolder
            foreach (string subFolder in Directory.GetDirectories(folder))
                LoadTemplatesRecursively(subFolder);
        }
Example #3
0
        /// <summary>
        /// Loads templates from the compiled Resources file
        /// </summary>
        void LoadTemplatesFromResources()
        {
            Template[] templates = new Template[]{
                new Template("CSHeader", Resources.CSHeader, "CSHeader.txt", "table,view", true),
                new Template("DALIndexes", Resources.DalIndexes, "DalIndexes.txt", "table,view", true),
                new Template("DALTables", Resources.DataAccessLayer, "DataAccessLayer.txt", "table", false),
                new Template("DALViews", Resources.DataAccessLayerForViews, "DataAccessLayerForViews.txt", "view", false),
                new Template("DataObject", Resources.DataObject, "DataObject.txt", "table,view", false),
                new Template("Delete", Resources.Delete, "Delete.txt", "table", false),
                new Template("GetAll", Resources.GetAll, "GetAll.txt", "table,view", false),
                new Template("GetByIndex", Resources.GetByIndex, "GetByIndex.txt", "table,view", false),
                new Template("Insert", Resources.Insert, "Insert.txt", "table", false),
                new Template("SPHeader", Resources.SPHeader, "SPHeader.txt", "table,view", true),
                new Template("Update", Resources.Update, "Update.txt", "table", false)
            };

            _templates.AddRange(templates);
        }