Exemple #1
0
        public List <CodeTemplate> CompileTemplates(ScaffoldViewModel model)
        {
            Dictionary <string, string> KeyVals = new Dictionary <string, string>();

            KeyVals.Add("<#= ModelTypeName #>", model.ModelName);
            KeyVals.Add("<#= ModelVariable #>", model.ModelName.ToLower());
            KeyVals.Add("<#= Namespace #>", model.Namespace);
            string json = JsonConvert.SerializeObject(KeyVals);

            List <ICompilable> compilers = new List <ICompilable>()
            {
                //new ModelTemplateInterpreter(_config),
                new ModuloInterpreter(),
                new KeyValReplacer(json)
            };

            List <CodeTemplate> templates = new List <CodeTemplate>();

            foreach (CodeTemplate template in DocProvider.GetTemplates(path))
            {
                foreach (ICompilable compiler in compilers)
                {
                    template.Content = compiler.Compile(template.Content);
                }
                templates.Add(template);
            }
            return(templates);
        }
Exemple #2
0
        public List <string> GetSnippets(string Filename)
        {
            List <string> snippets = new List <string>();

            foreach (CodeTemplate template in DocProvider.GetTemplates(path))
            {
                if (template.Name.Contains(Filename))
                {
                    string[] lines = template.Content.Split('~');
                    snippets = new List <string>(lines);
                }
            }
            return(snippets);
        }