public static BundleConfiguration AddBaseBundles(this BundleConfiguration bundleConfiguration, params string[] bundleNames)
        {
            Check.NotNull(bundleNames, nameof(bundleNames));

            bundleConfiguration.BaseBundles.AddRange(bundleNames);

            return(bundleConfiguration);
        }
        public static BundleConfiguration AddContributors(this BundleConfiguration bundleConfiguration, params Type[] contributorTypes)
        {
            Check.NotNull(contributorTypes, nameof(contributorTypes));

            foreach (var contributorType in contributorTypes)
            {
                bundleConfiguration.Contributors.Add(contributorType);
            }

            return(bundleConfiguration);
        }
        private BundleConfiguration CreateBundle(string bundleName, Action <BundleConfiguration> configureAction)
        {
            var bundle = new BundleConfiguration(bundleName);

            configureAction?.Invoke(bundle);

            if (_lazyBundleConfigurationActions.TryGetValue(bundleName, out var configurationActions))
            {
                lock (configurationActions)
                {
                    configurationActions.ForEach(c => c.Invoke(bundle));
                }
            }

            return(bundle);
        }
        /// <summary>
        /// Tries to add a new bundle with given <paramref name="bundleName"/>.
        /// Returns false if it's already created before.
        /// <paramref name="configureAction"/> is not called if it's already added before.
        /// </summary>
        /// <param name="bundleName">Bundle name.</param>
        /// <param name="configureAction">Initial configuration action.</param>
        /// <returns>Returns true if added. Returns false if it's already added before.</returns>
        public bool TryAdd([NotNull] string bundleName, [CanBeNull] Action <BundleConfiguration> configureAction = null)
        {
            Check.NotNull(bundleName, nameof(bundleName));

            if (_bundles.ContainsKey(bundleName))
            {
                return(false);
            }

            var bundle = new BundleConfiguration(bundleName);

            configureAction?.Invoke(bundle);

            if (_lazyBundleConfigurationActions.TryGetValue(bundleName, out var configurationActions))
            {
                lock (configurationActions)
                {
                    configurationActions.ForEach(c => c.Invoke(bundle));
                }
            }

            if (!_bundles.TryAdd(bundleName, bundle))
            {
                return(false);
            }

            if (configurationActions != null)
            {
                lock (configurationActions)
                {
                    configurationActions.Clear();
                }
            }

            return(true);
        }
 public static BundleConfiguration AddFiles(this BundleConfiguration bundleConfiguration, params string[] files)
 {
     bundleConfiguration.Contributors.AddFiles(files);
     return(bundleConfiguration);
 }