diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributorCollection.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributorCollection.cs index 1186086909..1bd62ff816 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributorCollection.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributorCollection.cs @@ -1,8 +1,8 @@ -using System; +using JetBrains.Annotations; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; -using JetBrains.Annotations; using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling @@ -18,6 +18,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling public void Add(BundleContributor contributor) { + foreach (var dependedType in GetDirectDependencies(contributor.GetType())) + { + AddWithDependencies(dependedType); + } + _contributors.Add(contributor); } @@ -39,11 +44,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling return _contributors.ToImmutableList(); } - private bool IsAlreadyAdded(Type contributorType) - { - return _contributors.Any(c => c.GetType() == contributorType); - } - private void AddWithDependencies(Type contributorType) { if (IsAlreadyAdded(contributorType)) @@ -51,20 +51,28 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling return; } + foreach (var dependedType in GetDirectDependencies(contributorType)) + { + AddWithDependencies(dependedType); //Recursive call + } + + AddInstanceToContributors(contributorType); + } + + private IEnumerable GetDirectDependencies(Type contributorType) + { var dependsOnAttributes = contributorType .GetCustomAttributes(true) .OfType() .ToList(); - foreach (var dependsOnAttribute in dependsOnAttributes) - { - foreach (var dependedType in dependsOnAttribute.GetDependedTypes()) - { - AddWithDependencies(dependedType); //Recursive call - } - } + return dependsOnAttributes + .SelectMany(a => a.GetDependedTypes()); + } - AddInstanceToContributors(contributorType); + private bool IsAlreadyAdded(Type contributorType) + { + return _contributors.Any(c => c.GetType() == contributorType); } private void AddInstanceToContributors(Type contributorType) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/AbpAspNetCoreMvcUIBasicThemeModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/AbpAspNetCoreMvcUIBasicThemeModule.cs index f68df35d1f..07f24165e3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/AbpAspNetCoreMvcUIBasicThemeModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/AbpAspNetCoreMvcUIBasicThemeModule.cs @@ -1,5 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AspNetCore.Mvc.UI.Bundling; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Toolbars; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; @@ -46,7 +45,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic { bundle .AddBaseBundles(StandardBundles.Styles.Global) - .AddContributors(new BasicThemeGlobalStyleContributor()); + .AddContributors(typeof(BasicThemeGlobalStyleContributor)); }); options