Ejemplo n.º 1
0
        private CSharpCompilation CompileViews(ViewCompilationInfo[] results, string assemblyname)
        {
            var compilation = compiler.CreateCompilation(assemblyname);
            var syntaxTrees = new SyntaxTree[results.Length];

            Parallel.For(0, results.Length, ParalellOptions, i =>
            {
                ViewCompilationInfo result = results[i];
                SourceText sourceText      = SourceText.From(result.CSharpDocument.GeneratedCode, Encoding.UTF8);

                TemplateFileInfo fileInfo = result.TemplateFileInfo;
                SyntaxTree syntaxTree     = compiler.CreateSyntaxTree(sourceText).WithFilePath(fileInfo.FullPath ?? fileInfo.ViewEnginePath);
                syntaxTrees[i]            = syntaxTree;
            });

            compilation = compilation.AddSyntaxTrees(syntaxTrees);
            compilation = ExpressionRewriter.Rewrite(compilation);

            compilation = AssemblyMetadataGenerator.AddAssemblyMetadata(
                compiler,
                compilation,
                Options);

            return(compilation);
        }
Ejemplo n.º 2
0
 public ViewCompilationInfo(
     TemplateFileInfo viewFileInfo,
     RazorCSharpDocument cSharpDocument)
 {
     TemplateFileInfo = viewFileInfo;
     CSharpDocument   = cSharpDocument;
 }