Ejemplo n.º 1
0
        /*
         * Return a file provider Type that an extension maps to.
         */
        internal static Type GetBuildProviderTypeFromExtension(VirtualPath configPath, string extension,
                                                               BuildProviderAppliesTo neededFor, bool failIfUnknown)
        {
            // Get the <compilation> config object
            CompilationSection config = MTConfigUtil.GetCompilationConfig(configPath);

            return(GetBuildProviderTypeFromExtension(config, extension, neededFor, failIfUnknown));
        }
Ejemplo n.º 2
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.º 3
0
        public static BuildProvider GetBuildProvider(VirtualPath virtualPath, BuildProviderCollection coll)
        {
            if (virtualPath == null || String.IsNullOrEmpty(virtualPath.Original) || coll == null)
            {
                return(null);
            }

            string        extension = virtualPath.Extension;
            BuildProvider bp        = coll.GetProviderForExtension(extension);

            if (bp == null)
            {
                if (String.Compare(extension, ".asax", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    bp = new ApplicationFileBuildProvider();
                }
                else if (StrUtils.StartsWith(virtualPath.AppRelative, "~/App_Themes/"))
                {
                    bp = new ThemeDirectoryBuildProvider();
                }

                if (bp != null)
                {
                    bp.SetVirtualPath(virtualPath);
                }

                return(bp);
            }

            object[] attrs = bp.GetType().GetCustomAttributes(typeof(BuildProviderAppliesToAttribute), true);
            if (attrs == null || attrs.Length == 0)
            {
                return(bp);
            }

            BuildProviderAppliesTo appliesTo = ((BuildProviderAppliesToAttribute)attrs [0]).AppliesTo;

            if ((appliesTo & BuildProviderAppliesTo.Web) == 0)
            {
                return(null);
            }

            bp.SetVirtualPath(virtualPath);
            return(bp);
        }
 public BuildProviderAppliesToAttribute(BuildProviderAppliesTo appliesTo)
 {
     this.appliesTo = appliesTo;
 }
 internal static Type GetBuildProviderTypeFromExtension(VirtualPath configPath, string extension, BuildProviderAppliesTo neededFor, bool failIfUnknown)
 {
     return GetBuildProviderTypeFromExtension(MTConfigUtil.GetCompilationConfig(configPath), extension, neededFor, failIfUnknown);
 }
 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.º 7
0
        internal static BuildProvider CreateBuildProvider(VirtualPath virtualPath,
            BuildProviderAppliesTo neededFor,
            CompilationSection compConfig, ICollection referencedAssemblies,
            bool failIfUnknown) {

            string extension = virtualPath.Extension;

            Type buildProviderType = CompilationUtil.GetBuildProviderTypeFromExtension(compConfig,
                extension, neededFor, failIfUnknown);
            if (buildProviderType == null)
                return null;

            object o = HttpRuntime.CreatePublicInstance(buildProviderType);

            BuildProvider buildProvider = (BuildProvider)o;

            buildProvider.SetVirtualPath(virtualPath);
            buildProvider.SetReferencedAssemblies(referencedAssemblies);

            return buildProvider;
        }
Ejemplo n.º 8
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.º 9
0
        /*
         * Return a file provider Type that an extension maps to.
         */
        internal static Type GetBuildProviderTypeFromExtension(VirtualPath configPath, string extension,
            BuildProviderAppliesTo neededFor, bool failIfUnknown) {

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

            return GetBuildProviderTypeFromExtension(config, extension, neededFor, failIfUnknown);
        }
	// Constructors
	public BuildProviderAppliesToAttribute(BuildProviderAppliesTo appliesTo) {}
 public BuildProviderAppliesToAttribute(BuildProviderAppliesTo appliesTo)
 {
 }
 public BuildProviderAppliesToAttribute(BuildProviderAppliesTo appliesTo)
 {
     this._appliesTo = appliesTo;
 }
Ejemplo n.º 13
0
 internal static Type GetBuildProviderTypeFromExtension(VirtualPath configPath, string extension, BuildProviderAppliesTo neededFor, bool failIfUnknown)
 {
     return(GetBuildProviderTypeFromExtension(MTConfigUtil.GetCompilationConfig(configPath), extension, neededFor, failIfUnknown));
 }
Ejemplo n.º 14
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.º 15
0
		public BuildProvider (string extension, string type, BuildProviderAppliesTo appliesTo)
		{
			this.extension = extension;
			this.type = type;
			this.appliesTo = appliesTo;
		}