Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Removes all the bundles from the collection.
 /// </summary>
 public void Clear()
 {
     _bundles.Clear();
     DynamicBundles.Clear();
     StaticBundles.Clear();
 }