From 815857daf1fea19a0cf7e5f8e12d33a464177e63 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 19 Jan 2021 16:19:55 +0800 Subject: [PATCH] Add ConfigureAll method to Bundle system --- .../Bundling/BundleConfigurationCollection.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs index afc4ec6a4a..a18e8bdd11 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs @@ -9,11 +9,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling { private readonly ConcurrentDictionary _bundles; private readonly ConcurrentDictionary>> _lazyBundleConfigurationActions; + private readonly List> _lazyAllBundleConfigurationActions; public BundleConfigurationCollection() { _bundles = new ConcurrentDictionary(); _lazyBundleConfigurationActions = new ConcurrentDictionary>>(); + _lazyAllBundleConfigurationActions = new List>(); } /// @@ -90,6 +92,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling } } + _lazyAllBundleConfigurationActions.ForEach(c => c.Invoke(bundle)); + return bundle; } @@ -123,6 +127,26 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling return this; } + /// + /// Configures all bundles. + /// This method also works for lazy bundles (those are created using razor tag helpers). + /// + /// Configure action + /// Returns this object for chained calls. + public BundleConfigurationCollection ConfigureAll([NotNull] Action configureAction) + { + Check.NotNull(configureAction, nameof(configureAction)); + + foreach (var bundle in _bundles) + { + configureAction.Invoke(bundle.Value); + } + + _lazyAllBundleConfigurationActions.Add(configureAction); + + return this; + } + /// /// Gets a bundle. /// @@ -140,4 +164,4 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling return bundle; } } -} \ No newline at end of file +}