public List <BuildProviderGroup> Build (bool single)
		{
			if (StrUtils.StartsWith (virtualPath.AppRelative, "~/App_Themes/")) {
				var themebp = new ThemeDirectoryBuildProvider ();
				themebp.SetVirtualPath (virtualPath);
				
				return GetSingleBuildProviderGroup (themebp);
			}

			CompilationSection section = CompilationSection;
			BuildProviderCollection bpcoll = section != null ? section.BuildProviders : null;

			if (bpcoll == null || bpcoll.Count == 0)
				return null;
			
			if (virtualPath.IsFake) {
				BuildProvider bp = GetBuildProvider (virtualPath, bpcoll);

				if (bp == null)
					return null;

				return GetSingleBuildProviderGroup (bp);
			}

			if (single) {
				AddVirtualFile (GetVirtualFile (virtualPath.Absolute), bpcoll);
			} else {
				var cache = new Dictionary <string, bool> (RuntimeHelpers.StringEqualityComparer);
				AddVirtualDir (GetVirtualDirectory (virtualPath.Absolute), bpcoll, cache);
				cache = null;
				if (buildProviders == null || buildProviders.Count == 0)
					AddVirtualFile (GetVirtualFile (virtualPath.Absolute), bpcoll);
			}

			if (buildProviders == null || buildProviders.Count == 0)
					return null;
			
			var buildProviderGroups = new List <BuildProviderGroup> ();
			foreach (BuildProvider bp in buildProviders.Values)
				AssignToGroup (bp, buildProviderGroups);

			if (buildProviderGroups == null || buildProviderGroups.Count == 0) {
				buildProviderGroups = null;
				return null;
			}
			
			// We need to reverse the order, so that the build happens from the least
			// dependant assemblies to the most dependant ones, more or less.
			buildProviderGroups.Reverse ();			
			
			return buildProviderGroups;
		}
        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 List <BuildProviderGroup> Build(bool single)
        {
            if (StrUtils.StartsWith(virtualPath.AppRelative, "~/App_Themes/"))
            {
                var themebp = new ThemeDirectoryBuildProvider();
                themebp.SetVirtualPath(virtualPath);

                return(GetSingleBuildProviderGroup(themebp));
            }

            CompilationSection      section = CompilationSection;
            BuildProviderCollection bpcoll  = section != null ? section.BuildProviders : null;

            if (bpcoll == null || bpcoll.Count == 0)
            {
                return(null);
            }

            if (virtualPath.IsFake)
            {
                BuildProvider bp = GetBuildProvider(virtualPath, bpcoll);

                if (bp == null)
                {
                    return(null);
                }

                return(GetSingleBuildProviderGroup(bp));
            }

            if (single)
            {
                AddVirtualFile(GetVirtualFile(virtualPath.Absolute), bpcoll);
            }
            else
            {
                var cache = new Dictionary <string, bool> (dictionaryComparer);
                AddVirtualDir(GetVirtualDirectory(virtualPath.Absolute), bpcoll, cache);
                cache = null;
                if (buildProviders == null || buildProviders.Count == 0)
                {
                    AddVirtualFile(GetVirtualFile(virtualPath.Absolute), bpcoll);
                }
            }

            if (buildProviders == null || buildProviders.Count == 0)
            {
                return(null);
            }

            var buildProviderGroups = new List <BuildProviderGroup> ();

            foreach (BuildProvider bp in buildProviders.Values)
            {
                AssignToGroup(bp, buildProviderGroups);
            }

            if (buildProviderGroups == null || buildProviderGroups.Count == 0)
            {
                buildProviderGroups = null;
                return(null);
            }

            // We need to reverse the order, so that the build happens from the least
            // dependant assemblies to the most dependant ones, more or less.
            buildProviderGroups.Reverse();

            return(buildProviderGroups);
        }
		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;
		}