示例#1
0
        internal static Type GetBuildProviderTypeFromExtension(CompilationSection config, string extension, BuildProviderAppliesTo neededFor, bool failIfUnknown)
        {
            BuildProviderInfo buildProviderInfo = System.Web.Compilation.BuildProvider.GetBuildProviderInfo(config, extension);
            Type c = null;

            if (((buildProviderInfo != null) && (buildProviderInfo.Type != typeof(IgnoreFileBuildProvider))) && (buildProviderInfo.Type != typeof(ForceCopyBuildProvider)))
            {
                c = buildProviderInfo.Type;
            }
            if (((neededFor == BuildProviderAppliesTo.Web) && BuildManager.PrecompilingForUpdatableDeployment) && !typeof(BaseTemplateBuildProvider).IsAssignableFrom(c))
            {
                c = null;
            }
            if (c != null)
            {
                if ((neededFor & buildProviderInfo.AppliesTo) != 0)
                {
                    return(c);
                }
            }
            else if ((neededFor != BuildProviderAppliesTo.Resources) && (config.GetCompilerInfoFromExtension(extension, false) != null))
            {
                return(typeof(SourceFileBuildProvider));
            }
            if (failIfUnknown)
            {
                throw new HttpException(System.Web.SR.GetString("Unknown_buildprovider_extension", new object[] { extension, neededFor.ToString() }));
            }
            return(null);
        }
        internal static BuildProviderInfo GetBuildProviderInfo(CompilationSection config, string extension)
        {
            System.Web.Configuration.BuildProvider provider = config.BuildProviders[extension];
            if (provider != null)
            {
                return(provider.BuildProviderInfo);
            }
            BuildProviderInfo info = null;

            s_dynamicallyRegisteredProviders.TryGetValue(extension, out info);
            return(info);
        }
        internal static BuildProviderInfo GetBuildProviderInfo(System.Web.Configuration.CompilationSection config, string extension)
        {
            Debug.Assert(extension != null);
            var entry = config.BuildProviders[extension];

            if (entry != null)
            {
                return(entry.BuildProviderInfo);
            }

            BuildProviderInfo info = null;

            s_dynamicallyRegisteredProviders.TryGetValue(extension, out info);
            return(info);
        }
示例#4
0
        internal static Type GetBuildProviderTypeFromExtension(CompilationSection config, string extension,
                                                               BuildProviderAppliesTo neededFor, bool failIfUnknown)
        {
            BuildProviderInfo providerInfo = BuildProvider.GetBuildProviderInfo(config, extension);

            Type buildProviderType = null;

            // Never return an IgnoreFileBuildProvider/ForceCopyBuildProvider, since it's just a marker
            if (providerInfo != null &&
                providerInfo.Type != typeof(IgnoreFileBuildProvider) &&
                providerInfo.Type != typeof(ForceCopyBuildProvider))
            {
                buildProviderType = providerInfo.Type;
            }

            // In updatable precomp mode, only aspx/ascx/master web files need processing.  Ignore the rest.
            if (neededFor == BuildProviderAppliesTo.Web &&
                BuildManager.PrecompilingForUpdatableDeployment &&
                !typeof(BaseTemplateBuildProvider).IsAssignableFrom(buildProviderType))
            {
                buildProviderType = null;
            }

            if (buildProviderType != null)
            {
                // Only return it if it applies to what it's needed for
                if ((neededFor & providerInfo.AppliesTo) != 0)
                {
                    return(buildProviderType);
                }
            }
            // If the extension is registered as a compiler extension, use
            // a SourceFileBuildProvider to handle it (not supported in Resources directory)
            else if (neededFor != BuildProviderAppliesTo.Resources &&
                     config.GetCompilerInfoFromExtension(extension, false /*throwOnFail*/) != null)
            {
                return(typeof(SourceFileBuildProvider));
            }

            if (failIfUnknown)
            {
                throw new HttpException(SR.GetString(SR.Unknown_buildprovider_extension, extension, neededFor.ToString()));
            }

            return(null);
        }
示例#5
0
        internal static bool NeedToCopyFile(VirtualPath virtualPath, bool updatable, out bool createStub)
        {
            createStub = false;
            CompilationSection compilationConfig = MTConfigUtil.GetCompilationConfig(virtualPath);
            string             extension         = virtualPath.Extension;
            BuildProviderInfo  buildProviderInfo = System.Web.Compilation.BuildProvider.GetBuildProviderInfo(compilationConfig, extension);

            if (buildProviderInfo != null)
            {
                if ((BuildProviderAppliesTo.Web & buildProviderInfo.AppliesTo) == 0)
                {
                    return(true);
                }
                if (buildProviderInfo.Type == typeof(ForceCopyBuildProvider))
                {
                    return(true);
                }
                if ((buildProviderInfo.Type != typeof(IgnoreFileBuildProvider)) && BuildManager.PrecompilingForUpdatableDeployment)
                {
                    return(true);
                }
                createStub = true;
                if (((buildProviderInfo.Type == typeof(UserControlBuildProvider)) || (buildProviderInfo.Type == typeof(MasterPageBuildProvider))) || (buildProviderInfo.Type == typeof(IgnoreFileBuildProvider)))
                {
                    createStub = false;
                }
                return(false);
            }
            if (compilationConfig.GetCompilerInfoFromExtension(extension, false) != null)
            {
                return(false);
            }
            if (System.Web.Util.StringUtil.EqualsIgnoreCase(extension, ".asax"))
            {
                return(false);
            }
            if (!updatable && System.Web.Util.StringUtil.EqualsIgnoreCase(extension, ".skin"))
            {
                return(false);
            }
            return(true);
        }
 internal BuildProvider() {
     _info = new ConfigurationBuildProviderInfo(this);
 }
示例#7
0
        // This is used to determine what files need to be copied, and what stub files
        // need to be created during deployment precompilation.
        // Note: createStub only applies if the method returns false.
        internal static bool NeedToCopyFile(VirtualPath virtualPath, bool updatable, out bool createStub)
        {
            createStub = false;

            // Get the <compilation> config object
            CompilationSection config = MTConfigUtil.GetCompilationConfig(virtualPath);

            string extension = virtualPath.Extension;

            BuildProviderInfo providerInfo = BuildProvider.GetBuildProviderInfo(config, extension);

            if (providerInfo != null)
            {
                // We only care about 'web' providers.  Everything else we treat as static
                if ((BuildProviderAppliesTo.Web & providerInfo.AppliesTo) == 0)
                {
                    return(true);
                }

                // If the provider is a ForceCopyBuildProvider, treat as static
                if (providerInfo.Type == typeof(ForceCopyBuildProvider))
                {
                    return(true);
                }

                // During updatable precomp, everything needs to be copied over.  However,
                // aspx files that use code beside will later be overwritten by modified
                // versions (see TemplateParser.CreateModifiedMainDirectiveFileIfNeeded)
                if (providerInfo.Type != typeof(IgnoreFileBuildProvider) &&
                    BuildManager.PrecompilingForUpdatableDeployment)
                {
                    return(true);
                }

                // There is a real provider, so don't copy the file.  We also need to determine whether
                // a stub file needs to be created.

                createStub = true;

                // Skip the stub file for some non-requestable types
                if (providerInfo.Type == typeof(UserControlBuildProvider) ||
                    providerInfo.Type == typeof(MasterPageBuildProvider) ||
                    providerInfo.Type == typeof(IgnoreFileBuildProvider))
                {
                    createStub = false;
                }

                return(false);
            }

            // If the extension is registered as a compiler extension, don't copy
            if (config.GetCompilerInfoFromExtension(extension, false /*throwOnFail*/) != null)
            {
                return(false);
            }

            // Skip the copying for asax and skin files, which are not static even though they
            // don't have a registered BuildProvider (but don't skip .skin files during
            // updatable precomp).
            //
            if (StringUtil.EqualsIgnoreCase(extension, ".asax"))
            {
                return(false);
            }
            if (!updatable && StringUtil.EqualsIgnoreCase(extension, ThemeDirectoryCompiler.skinExtension))
            {
                return(false);
            }

            //
            // If there is no BuildProvider registered, it's a static file, and should be copied
            //

            return(true);
        }
示例#8
0
 internal BuildProvider()
 {
     this._info = new ConfigurationBuildProviderInfo(this);
 }