+
+ private CompilerResults CompileFromDomBatch (CompilerParameters options, CodeCompileUnit[] ea)
+ {
+ if (options == null) {
+ throw new ArgumentNullException ("options");
+ }
+
+ if (ea == null) {
+ throw new ArgumentNullException ("ea");
+ }
+
+ string[] fileNames = new string[ea.Length];
+ StringCollection assemblies = options.ReferencedAssemblies;
+
+ for (int i = 0; i < ea.Length; i++) {
+ CodeCompileUnit compileUnit = ea[i];
+ fileNames[i] = GetTempFileNameWithExtension (options.TempFiles, i + ".cs");
+ FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
+ StreamWriter s = new StreamWriter (f, Encoding.UTF8);
+ if (compileUnit.ReferencedAssemblies != null) {
+ foreach (string str in compileUnit.ReferencedAssemblies) {
+ if (!assemblies.Contains (str))
+ assemblies.Add (str);
+ }
+ }
+
+ ((ICodeGenerator) this).GenerateCodeFromCompileUnit (compileUnit, s, new CodeGeneratorOptions ());
+ s.Close ();
+ f.Close ();
+ }
+ return CompileAssemblyFromFileBatch (options, fileNames);
+ }
+
+ private CompilerResults CompileFromSourceBatch (CompilerParameters options, string[] sources)
+ {
+ if (options == null) {
+ throw new ArgumentNullException ("options");
+ }
+
+ if (sources == null) {
+ throw new ArgumentNullException ("sources");
+ }
+
+ string[] fileNames = new string[sources.Length];
+
+ for (int i = 0; i < sources.Length; i++) {
+ fileNames[i] = GetTempFileNameWithExtension (options.TempFiles, i + ".cs");
+ FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
+ using (StreamWriter s = new StreamWriter (f, Encoding.UTF8)) {
+ s.Write (sources[i]);
+ s.Close ();
+ }
+ f.Close ();
+ }
+ return CompileFromFileBatch (options, fileNames);
+ }