Ejemplo n.º 1
0
        /*
         * Return a CompilerType that a extension maps to.
         */
        private static CompilerType GetCompilerInfoFromExtension(VirtualPath configPath, string extension)
        {
            // Get the <compilation> config object
            CompilationSection config = MTConfigUtil.GetCompilationConfig(configPath);

            return(config.GetCompilerInfoFromExtension(extension, true /*throwOnFail*/));
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }