public override void CompileView(IEnumerable<IList<Chunk>> viewTemplates, IEnumerable<IList<Chunk>> allResources) { GenerateSourceCode(viewTemplates, allResources); var compiler = new BatchCompiler(); var assembly = compiler.Compile(Debug, "csharp", SourceCode); CompiledType = assembly.GetType(ViewClassFullName); }
public Assembly BatchCompilation(string outputAssembly, IList<SparkViewDescriptor> descriptors) { var batch = new List<CompiledViewEntry>(); var sourceCode = new List<string>(); foreach (var descriptor in descriptors) { var entry = new CompiledViewEntry { Descriptor = descriptor, Loader = CreateViewLoader(), Compiler = LanguageFactory.CreateViewCompiler(this, descriptor) }; var chunksLoaded = new List<IList<Chunk>>(); var templatesLoaded = new List<string>(); LoadTemplates(entry.Loader, descriptor.Templates, chunksLoaded, templatesLoaded); entry.Compiler.GenerateSourceCode(chunksLoaded, entry.Loader.GetEverythingLoaded()); sourceCode.Add(entry.Compiler.SourceCode); batch.Add(entry); } var batchCompiler = new BatchCompiler { OutputAssembly = outputAssembly }; var assembly = batchCompiler.Compile(Settings.Debug, sourceCode.ToArray()); foreach (var entry in batch) { entry.Compiler.CompiledType = assembly.GetType(entry.Compiler.ViewClassFullName); entry.Activator = ViewActivatorFactory.Register(entry.Compiler.CompiledType); CompiledViewHolder.Current.Store(entry); } return assembly; }