public Bundle GetBundleFor(string bundleVirtualPath) { Exception error = ExceptionUtil.ValidateVirtualPath(bundleVirtualPath, "bundleVirtualPath"); if (error != null) { throw error; } // Search for exact path match first if (StaticBundles.ContainsKey(bundleVirtualPath)) { return(StaticBundles[bundleVirtualPath]); } if (DynamicBundles.Count > 0) { // Otherwise look at virtualPath component for a bundle extension match bundleVirtualPath = bundleVirtualPath.Replace("\\", "/"); int index = bundleVirtualPath.LastIndexOf("/", StringComparison.Ordinal); // Note: virtualPath always starts with ~/ so should be never -1; string last = bundleVirtualPath.Substring(index + 1); if (DynamicBundles.ContainsKey(last)) { return(DynamicBundles[last]); } } return(null); }
/// <summary> /// Removes a single bundle from the collection. /// </summary> /// <param name="bundle">The bundle to remove from the collection.</param> /// <returns>A boolean value indicating whether the bundle was succesfully removed from the collection.</returns> public bool Remove(Bundle bundle) { if (bundle == null) { throw new ArgumentNullException("bundle"); } bool wasRemoved = _bundles.Remove(bundle.Path); if (wasRemoved) { if (bundle is DynamicFolderBundle) { DynamicBundles.Remove(bundle.Path); } else { StaticBundles.Remove(bundle.Path); } } return(wasRemoved); }
/// <summary> /// Removes all the bundles from the collection. /// </summary> public void Clear() { _bundles.Clear(); DynamicBundles.Clear(); StaticBundles.Clear(); }