@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.Immutable ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
using Microsoft.AspNetCore.Hosting ;
using Microsoft.Extensions.Hosting ;
using Microsoft.Extensions.Logging ;
@ -58,21 +59,21 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
Logger = NullLogger < BundleManager > . Instance ;
}
public virtual IReadOnlyList < string > GetStyleBundleFiles ( string bundleName )
public virtual async Task < IReadOnlyList < string > > GetStyleBundleFilesAsync ( string bundleName )
{
return GetBundleFiles ( Options . StyleBundles , bundleName , StyleBundler ) ;
return await GetBundleFilesAsync ( Options . StyleBundles , bundleName , StyleBundler ) ;
}
public virtual IReadOnlyList < string > GetScriptBundleFiles ( string bundleName )
public virtual async Task < IReadOnlyList < string > > GetScriptBundleFilesAsync ( string bundleName )
{
return GetBundleFiles ( Options . ScriptBundles , bundleName , ScriptBundler ) ;
return await GetBundleFilesAsync ( Options . ScriptBundles , bundleName , ScriptBundler ) ;
}
protected virtual IReadOnlyList < string > GetBundleFiles ( BundleConfigurationCollection bundles , string bundleName , IBundler bundler )
protected virtual async Task < IReadOnlyList < string > > GetBundleFilesAsync ( BundleConfigurationCollection bundles , string bundleName , IBundler bundler )
{
var contributors = GetContributors ( bundles , bundleName ) ;
var bundleFiles = RequestResources . TryAdd ( GetBundleFiles ( contributors ) ) ;
var dynamicResources = RequestResources . TryAdd ( GetDynamicResources ( contributors ) ) ;
var bundleFiles = RequestResources . TryAdd ( await GetBundleFilesAsync ( contributors ) ) ;
var dynamicResources = RequestResources . TryAdd ( await GetDynamicResourcesAsync ( contributors ) ) ;
if ( ! IsBundlingEnabled ( ) )
{
@ -178,22 +179,36 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
}
}
protected virtu al List < string > GetBundleFiles ( List < BundleContributor > contributors )
protected async Task < List < string > > GetBundleFilesAsync ( List < I BundleContributor> contributors )
{
var context = CreateBundleConfigurationContext ( ) ;
contributors . ForEach ( c = > c . PreConfigureBundle ( context ) ) ;
contributors . ForEach ( c = > c . ConfigureBundle ( context ) ) ;
contributors . ForEach ( c = > c . PostConfigureBundle ( context ) ) ;
foreach ( var contributor in contributors )
{
await contributor . PreConfigureBundleAsync ( context ) ;
}
foreach ( var contributor in contributors )
{
await contributor . ConfigureBundleAsync ( context ) ;
}
foreach ( var contributor in contributors )
{
await contributor . PostConfigureBundleAsync ( context ) ;
}
return context . Files ;
}
protected virtual List < string > GetDynamicResources ( List < BundleContributor > contributors )
protected virtual async Task < List < string > > GetDynamicResourcesAsync ( List < I BundleContributor> contributors )
{
var context = CreateBundleConfigurationContext ( ) ;
contributors . ForEach ( c = > c . ConfigureDynamicResources ( context ) ) ;
foreach ( var contributor in contributors )
{
await contributor . ConfigureDynamicResourcesAsync ( context ) ;
}
return context . Files ;
}
@ -203,9 +218,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
return new BundleConfigurationContext ( ServiceProvider , WebContentFileProvider ) ;
}
protected virtual List < BundleContributor > GetContributors ( BundleConfigurationCollection bundles , string bundleName )
protected virtual List < I BundleContributor> GetContributors ( BundleConfigurationCollection bundles , string bundleName )
{
var contributors = new List < BundleContributor > ( ) ;
var contributors = new List < I BundleContributor> ( ) ;
AddContributorsWithBaseBundles ( contributors , bundles , bundleName ) ;
@ -222,7 +237,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
return contributors ;
}
protected virtual void AddContributorsWithBaseBundles ( List < BundleContributor > contributors , BundleConfigurationCollection bundles , string bundleName )
protected virtual void AddContributorsWithBaseBundles ( List < I BundleContributor> contributors , BundleConfigurationCollection bundles , string bundleName )
{
var bundleConfiguration = bundles . Get ( bundleName ) ;