BuildProvider GetBuildProviderFor(string file, BuildProviderCollection buildProviders) { if (file == null || file.Length == 0 || buildProviders == null || buildProviders.Count == 0) { return(null); } BuildProvider ret = buildProviders.GetProviderForExtension(Path.GetExtension(file)); if (ret != null && IsCorrectBuilderType(ret)) { ret.SetVirtualPath(PhysicalToVirtual(file)); return(ret); } return(null); }
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); }