System.CodeDom.Compiler.CodeCompiler.FromDomBatch C# (CSharp) Method

FromDomBatch() protected method

protected FromDomBatch ( CompilerParameters options, CodeCompileUnit ea ) : CompilerResults
options CompilerParameters
ea System.CodeDom.CodeCompileUnit
return CompilerResults
        protected virtual CompilerResults FromDomBatch(CompilerParameters options, CodeCompileUnit[] ea) {
            if( options == null) {
                throw new ArgumentNullException("options");
            }
            if (ea == null)
                throw new ArgumentNullException("ea");

            new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

            string[] filenames = new string[ea.Length];

            CompilerResults results = null;
            
                    for (int i = 0; i < ea.Length; i++) {
                        if (ea[i] == null)
                            continue;       // the other two batch methods just work if one element is null, so we'll match that. 
                        
                        ResolveReferencedAssemblies(options, ea[i]);
                        filenames[i] = options.TempFiles.AddExtension(i + FileExtension);
                        Stream temp = new FileStream(filenames[i], FileMode.Create, FileAccess.Write, FileShare.Read);
                        try {
                            using (StreamWriter sw = new StreamWriter(temp, Encoding.UTF8)){
                                ((ICodeGenerator)this).GenerateCodeFromCompileUnit(ea[i], sw, Options);
                                sw.Flush();
                            }
                        }
                        finally {
                            temp.Close();
                        }
                    }

                    results = FromFileBatch(options, filenames);
            return results;
        }