Type GetBuildProviderCodeDomType(BuildProvider bp)
        {
            CompilerType ct = bp.CodeCompilerType;

            if (ct == null)
            {
                string language = bp.LanguageName;

                if (String.IsNullOrEmpty(language))
                {
                    language = CompilationSection.DefaultLanguage;
                }

                ct = BuildManager.GetDefaultCompilerTypeForLanguage(language, CompilationSection, false);
            }

            Type ret = ct != null ? ct.CodeDomProviderType : null;

            if (ret == null)
            {
                throw new HttpException("Unable to determine code compilation language provider for virtual path '" + bp.VirtualPath + "'.");
            }

            return(ret);
        }
Esempio n. 2
0
        public void AddProvider(BuildProvider bp)
        {
            if (Count == 0)
            {
                // We need to set the name prefix
                if (bp is ApplicationFileBuildProvider)
                {
                    NamePrefix  = "App_global.asax";
                    Application = true;
                }
                else if (bp is ThemeDirectoryBuildProvider)
                {
                    NamePrefix = "App_Theme";
                    Master     = true;
                }
                else
                {
                    NamePrefix = "App_Web";
                }

                CompilerType ct = BuildManager.GetDefaultCompilerTypeForLanguage(bp.LanguageName, null);
                if (ct != null)
                {
                    CompilerType = ct;
                }
            }

            Add(bp);
        }
Esempio n. 3
0
        public void Compile()
        {
            string refsPath = Path.Combine(HttpRuntime.AppDomainAppPath, ResourcesDirName);

            if (!Directory.Exists(refsPath))
            {
                return;
            }

            string[] files = Directory.GetFiles(refsPath, "*.wsdl", SearchOption.AllDirectories);
            if (files == null || files.Length == 0)
            {
                return;
            }

            CompilationSection cs = WebConfigurationManager.GetWebApplicationSection("system.web/compilation") as CompilationSection;

            if (cs == null)
            {
                throw new HttpException("Unable to determine default compilation language.");
            }

            CompilerType    ct = BuildManager.GetDefaultCompilerTypeForLanguage(cs.DefaultLanguage, cs);
            CodeDomProvider codeDomProvider  = null;
            Exception       codeDomException = null;

            try {
                codeDomProvider = Activator.CreateInstance(ct.CodeDomProviderType) as CodeDomProvider;
            } catch (Exception e) {
                codeDomException = e;
            }

            if (codeDomProvider == null)
            {
                throw new HttpException("Unable to instantiate default compilation language provider.", codeDomException);
            }

            AssemblyBuilder ab = new AssemblyBuilder(codeDomProvider, "App_WebReferences_");

            ab.CompilerOptions = ct.CompilerParameters;

            VirtualPath       vp;
            WsdlBuildProvider wbp;

            foreach (string file in files)
            {
                vp = VirtualPath.PhysicalToVirtual(file);
                if (vp == null)
                {
                    continue;
                }

                wbp = new WsdlBuildProvider();
                wbp.SetVirtualPath(vp);
                wbp.GenerateCode(ab);
            }

            CompilerResults results;

            try {
                results = ab.BuildAssembly();
            } catch (CompilationException ex) {
                throw new HttpException("Failed to compile web references.", ex);
            }

            if (results == null)
            {
                return;
            }

            Assembly asm = results.CompiledAssembly;

            BuildManager.TopLevelAssemblies.Add(asm);
        }
Esempio n. 4
0
 protected CompilerType GetDefaultCompilerType()
 {
     return(BuildManager.GetDefaultCompilerTypeForLanguage(CompilationConfig.DefaultLanguage, CompilationConfig));
 }
Esempio n. 5
0
 protected CompilerType GetDefaultCompilerTypeForLanguage(string language)
 {
     return(BuildManager.GetDefaultCompilerTypeForLanguage(language, null));
 }