public GeneratorResults GenerateCode(ViewDescriptor<IRazorTemplate> descriptor, string className, RazorEngineHost host)
         {
             var engine = new RazorTemplateEngine(host);
             GeneratorResults results;
             using (var fileStream = new FileStream(descriptor.Template.FilePath, FileMode.Open, FileAccess.Read))
             using (var reader = new StreamReader(fileStream))
             {
                 results = engine.GenerateCode(reader, className, host.DefaultNamespace, descriptor.ViewPath);
             }

             if (!results.Success)
             {
                 throw CreateExceptionFromParserError(results.ParserErrors.Last(), descriptor.Name());
             }
             return results;
         }
Пример #2
0
        public GeneratorResults GenerateCode(ViewDescriptor <IRazorTemplate> descriptor, string className, RazorEngineHost host)
        {
            var engine = new RazorTemplateEngine(host);
            GeneratorResults results;

            using (var fileStream = new FileStream(descriptor.Template.FilePath, FileMode.Open, FileAccess.Read))
                using (var reader = new StreamReader(fileStream))
                {
                    results = engine.GenerateCode(reader, className, host.DefaultNamespace, descriptor.ViewPath);
                }

            if (!results.Success)
            {
                throw CreateExceptionFromParserError(results.ParserErrors.Last(), descriptor.Name());
            }
            return(results);
        }
Пример #3
0
 public string Name()
 {
     return(_descriptor.Name());
 }