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

FromSourceBatch() protected method

protected FromSourceBatch ( CompilerParameters options, string sources ) : CompilerResults
options CompilerParameters
sources string
return CompilerResults
        protected virtual CompilerResults FromSourceBatch(CompilerParameters options, string[] sources) {
            if( options == null) {
                throw new ArgumentNullException("options");
            }
            if (sources == null)
                throw new ArgumentNullException("sources");

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

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

            CompilerResults results = null;
                    for (int i = 0; i < sources.Length; i++) {
                        string name = options.TempFiles.AddExtension(i + FileExtension);
                        Stream temp = new FileStream(name, FileMode.Create, FileAccess.Write, FileShare.Read);
                        try {
                            using (StreamWriter sw = new StreamWriter(temp, Encoding.UTF8)) {
                                sw.Write(sources[i]);
                                sw.Flush();
                            }
                        }
                        finally {
                            temp.Close();
                        }
                        filenames[i] = name;
                   }
                   results = FromFileBatch(options, filenames);

            return results;
        }