Ejemplo n.º 1
0
        public Template(ProjectItem projectItem)
        {
            var stopwatch = Stopwatch.StartNew();

            _projectItem  = projectItem;
            _templatePath = projectItem.Path();
            _projectPath  = Path.GetDirectoryName(projectItem.ContainingProject.FullName);

            var code = System.IO.File.ReadAllText(_templatePath);

            _template = TemplateCodeParser.Parse(code, _customExtensions);

            stopwatch.Stop();
            Log.Debug("Template ctor {0} ms", stopwatch.ElapsedMilliseconds);
        }
Ejemplo n.º 2
0
        public Template(ProjectItem projectItem)
        {
            var stopwatch = Stopwatch.StartNew();

            this.projectItem  = projectItem;
            this.templatePath = projectItem.Path();
            this.projectPath  = Path.GetDirectoryName(projectItem.ContainingProject.FullName);
            this.solutionPath = Path.GetDirectoryName(projectItem.DTE.Solution.FullName) + @"\";

            var code = System.IO.File.ReadAllText(templatePath);

            this.template = TemplateCodeParser.Parse(code, ref this.extensions);

            stopwatch.Stop();
            Log.Debug("Template ctor {0} ms", stopwatch.ElapsedMilliseconds);
        }
Ejemplo n.º 3
0
        private Lazy <string> LazyTemplate()
        {
            _templateCompiled         = false;
            _templateCompileException = false;

            return(new Lazy <string>(() =>
            {
                var code = System.IO.File.ReadAllText(_templatePath);
                try
                {
                    var result = TemplateCodeParser.Parse(_projectItem, code, _customExtensions);
                    _templateCompiled = true;

                    return result;
                }
                catch (Exception)
                {
                    _templateCompileException = true;
                    throw;
                }
            }));
        }