private static void BatchCompileInternal(string virtualDir, HttpContext context) { string directory = context.Request.MapPath(virtualDir); // Prescan all files in the current directory to see inter-file dependencies DirectoryInfo filesDirectory = new DirectoryInfo(directory); BatchTemplateParser btp = new BatchTemplateParser(context); AddFileSet(virtualDir, filesDirectory, "*.aspx", btp); AddFileSet(virtualDir, filesDirectory, "*.ascx", btp); // Based on dependencies, split into phases SourceReference[][] sources = BatchDependencyWalker.Split(btp.GetSourceReferences()); btp = null; // Tell the server that we're still running to make sure it doesn't kill us (ASURT 96452) context.SendEmptyResponse(); #if DBG for (int i = 0; i < sources.Length; i++) { SourceReference[] bucket = sources[i]; Debug.Trace("Batching", ""); Debug.Trace("Batching", "Bucket " + i + " contains " + bucket.Length + " files"); for (int j = 0; j < bucket.Length; j++) { Debug.Trace("Batching", bucket[j].Filename); } } #endif // Batch compile each phase separately for (int i = 0; i < sources.Length; i++) { SourceReference[] batch = sources[i]; ArrayList list = new ArrayList(); // cons up the TemplateParserParameters for (int j = 0; j < batch.Length; j++) { string filename = batch[j].Filename; string virtualPath = UrlPath.Combine(virtualDir, Path.GetFileName(filename)); list.Add(new BatchCompilationEntry(virtualPath, filename, context)); } // Now batch compile them if (list.Count > 0) { BatchCompile(list, context, virtualDir); } } }
private static void AddFileSet(string virtualDir, DirectoryInfo filesDirectory, string searchString, BatchTemplateParser btp) { FileInfo[] files = filesDirectory.GetFiles(searchString); for (int index = 0; index < files.Length; ++index) { FileInfo file = files[index]; if ((file.Attributes & FileAttributes.Directory) != 0) { continue; } // Set the virtual path of the current file in the parser string currentVirtualPath = UrlPath.Combine(virtualDir, file.Name); btp.CurrentVirtualPath = currentVirtualPath; Debug.Trace("Batching", "CodeDomBatching file " + file.Name + " (" + currentVirtualPath + ")"); btp.AddSource(file.FullName); } }