|
|
@ -53,7 +53,7 @@ namespace Volo.Abp.Cli.Bundling |
|
|
var startupModule = GetStartupModule(assemblyFilePath); |
|
|
var startupModule = GetStartupModule(assemblyFilePath); |
|
|
|
|
|
|
|
|
var bundleDefinitions = new List<BundleTypeDefinition>(); |
|
|
var bundleDefinitions = new List<BundleTypeDefinition>(); |
|
|
FindBundleContributersRecursively(startupModule, 0, bundleDefinitions); |
|
|
FindBundleContributorsRecursively(startupModule, 0, bundleDefinitions); |
|
|
bundleDefinitions = bundleDefinitions.OrderByDescending(t => t.Level).ToList(); |
|
|
bundleDefinitions = bundleDefinitions.OrderByDescending(t => t.Level).ToList(); |
|
|
|
|
|
|
|
|
var styleContext = GetStyleContext(bundleDefinitions); |
|
|
var styleContext = GetStyleContext(bundleDefinitions); |
|
|
@ -89,8 +89,8 @@ namespace Volo.Abp.Cli.Bundling |
|
|
|
|
|
|
|
|
foreach (var bundleDefinition in bundleDefinitions) |
|
|
foreach (var bundleDefinition in bundleDefinitions) |
|
|
{ |
|
|
{ |
|
|
var contributer = CreateContributerInstance(bundleDefinition.BundleContributerType); |
|
|
var contributor = CreateContributerInstance(bundleDefinition.BundleContributerType); |
|
|
contributer.AddScripts(scriptContext); |
|
|
contributor.AddScripts(scriptContext); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
scriptContext.Add("_framework/blazor.webassembly.js"); |
|
|
scriptContext.Add("_framework/blazor.webassembly.js"); |
|
|
@ -103,8 +103,8 @@ namespace Volo.Abp.Cli.Bundling |
|
|
|
|
|
|
|
|
foreach (var bundleDefinition in bundleDefinitions) |
|
|
foreach (var bundleDefinition in bundleDefinitions) |
|
|
{ |
|
|
{ |
|
|
var contributer = CreateContributerInstance(bundleDefinition.BundleContributerType); |
|
|
var contributor = CreateContributerInstance(bundleDefinition.BundleContributerType); |
|
|
contributer.AddStyles(styleContext); |
|
|
contributor.AddStyles(styleContext); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return styleContext; |
|
|
return styleContext; |
|
|
@ -190,25 +190,25 @@ namespace Volo.Abp.Cli.Bundling |
|
|
return (IBundleContributor)Activator.CreateInstance(bundleContributerType); |
|
|
return (IBundleContributor)Activator.CreateInstance(bundleContributerType); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void FindBundleContributersRecursively( |
|
|
private void FindBundleContributorsRecursively( |
|
|
Type module, |
|
|
Type module, |
|
|
int level, |
|
|
int level, |
|
|
List<BundleTypeDefinition> bundleDefinitions) |
|
|
List<BundleTypeDefinition> bundleDefinitions) |
|
|
{ |
|
|
{ |
|
|
var bundleContributers = module.Assembly |
|
|
var bundleContributors = module.Assembly |
|
|
.GetTypes() |
|
|
.GetTypes() |
|
|
.Where(t => t.IsAssignableTo<IBundleContributor>()) |
|
|
.Where(t => t.IsAssignableTo<IBundleContributor>()) |
|
|
.ToList(); |
|
|
.ToList(); |
|
|
|
|
|
|
|
|
if (bundleContributers.Count > 1) |
|
|
if (bundleContributors.Count > 1) |
|
|
{ |
|
|
{ |
|
|
throw new BundlingException($"Each project must contain only one class implementing {nameof(IBundleContributor)}"); |
|
|
throw new BundlingException($"Each project must contain only one class implementing {nameof(IBundleContributor)}"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (bundleContributers.Any()) |
|
|
if (bundleContributors.Any()) |
|
|
{ |
|
|
{ |
|
|
var bundleContributer = bundleContributers[0]; |
|
|
var bundleContributor = bundleContributors[0]; |
|
|
var definition = bundleDefinitions.SingleOrDefault(t => t.BundleContributerType == bundleContributer); |
|
|
var definition = bundleDefinitions.SingleOrDefault(t => t.BundleContributerType == bundleContributor); |
|
|
if (definition != null) |
|
|
if (definition != null) |
|
|
{ |
|
|
{ |
|
|
if (definition.Level < level) |
|
|
if (definition.Level < level) |
|
|
@ -221,7 +221,7 @@ namespace Volo.Abp.Cli.Bundling |
|
|
bundleDefinitions.Add(new BundleTypeDefinition |
|
|
bundleDefinitions.Add(new BundleTypeDefinition |
|
|
{ |
|
|
{ |
|
|
Level = level, |
|
|
Level = level, |
|
|
BundleContributerType = bundleContributer |
|
|
BundleContributerType = bundleContributor |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -234,7 +234,7 @@ namespace Volo.Abp.Cli.Bundling |
|
|
{ |
|
|
{ |
|
|
foreach (var dependedModuleType in descriptor.GetDependedTypes()) |
|
|
foreach (var dependedModuleType in descriptor.GetDependedTypes()) |
|
|
{ |
|
|
{ |
|
|
FindBundleContributersRecursively(dependedModuleType, level + 1, bundleDefinitions); |
|
|
FindBundleContributorsRecursively(dependedModuleType, level + 1, bundleDefinitions); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|