GetOptions() 정적인 개인적인 메소드

static private GetOptions ( ICollection assemblies ) : CompilerParameters
assemblies ICollection
리턴 System.CodeDom.Compiler.CompilerParameters
예제 #1
0
        public override Type GetCompiledType()
        {
            Type type = CachingCompiler.GetTypeFromCache(parser.PhysicalPath);

            if (type != null)
            {
                return(type);
            }

            if (parser.Program.Trim() == "")
            {
                type = Type.GetType(parser.ClassName, false);
                if (type == null)
                {
                    type = parser.GetTypeFromBin(parser.ClassName);
                }
                CachingCompiler.InsertTypeFileDep(type, parser.PhysicalPath);
                return(type);
            }

            string lang = parser.Language;
            string compilerOptions;
            string tempdir;
            int    warningLevel;

            CodeDomProvider provider;

            Provider = provider = CreateProvider(parser.Context, lang, out compilerOptions, out warningLevel, out tempdir);
            if (Provider == null)
            {
                throw new HttpException("Configuration error. Language not supported: " +
                                        lang, 500);
            }

            CompilerParameters compilerParameters;

            CompilerParameters = compilerParameters = CachingCompiler.GetOptions(parser.Assemblies);
            compilerParameters.IncludeDebugInformation = parser.Debug;
            compilerParameters.CompilerOptions         = compilerOptions;
            compilerParameters.WarningLevel            = warningLevel;

            bool keepFiles = (Environment.GetEnvironmentVariable("MONO_ASPNET_NODELETE") != null);

            TempFileCollection tempcoll;

            tempcoll = new TempFileCollection(tempdir, keepFiles);
            compilerParameters.TempFiles = tempcoll;

            inputFile = tempcoll.AddExtension(provider.FileExtension);
            Stream       st = File.OpenWrite(inputFile);
            StreamWriter sw = new StreamWriter(st);

            sw.WriteLine(parser.Program);
            sw.Close();

            string dllfilename = Path.GetFileName(tempcoll.AddExtension("dll", true));

            compilerParameters.OutputAssembly = Path.Combine(DynamicDir(), dllfilename);

            CompilerResults results = CachingCompiler.Compile(this);

            CheckCompilerErrors(results);
            Assembly assembly = results.CompiledAssembly;

            if (assembly == null)
            {
                if (!File.Exists(compilerParameters.OutputAssembly))
                {
                    throw new CompilationException(inputFile, results.Errors,
                                                   "No assembly returned after compilation!?");
                }
                assembly = Assembly.LoadFrom(compilerParameters.OutputAssembly);
            }

            results.TempFiles.Delete();
            type = assembly.GetType(parser.ClassName, true);
            CachingCompiler.InsertTypeFileDep(type, parser.PhysicalPath);
            return(type);
        }