Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Plugin manager - Add related assemblies (for plugin)

KrzysztofPajak83560c9b9fb5
diff --git a/src/Core/Grand.Infrastructure/Plugins/PluginManager.cs b/src/Core/Grand.Infrastructure/Plugins/PluginManager.cs
index e36000111..cade2beb5 100644
--- a/src/Core/Grand.Infrastructure/Plugins/PluginManager.cs
+++ b/src/Core/Grand.Infrastructure/Plugins/PluginManager.cs
@@ -1,5 +1,6 @@
using Grand.Infrastructure.Configuration;
using Grand.SharedKernel.Extensions;
+using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using System;
@@ -342,6 +343,16 @@ namespace Grand.Infrastructure.Plugins
//we can now register the plugin definition
Log.Information("Adding to ApplicationParts: '{0}'", systemName);
mvcCoreBuilder.AddApplicationPart(assembly);
+
+ var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(assembly, throwOnError: false);
+ foreach (var relatedAssembly in relatedAssemblies)
+ {
+ var applicationPartFactory = ApplicationPartFactory.GetApplicationPartFactory(relatedAssembly);
+ foreach (var part in applicationPartFactory.GetApplicationParts(relatedAssembly))
+ {
+ mvcCoreBuilder.PartManager.ApplicationParts.Add(part);
+ }
+ }
}
catch (Exception ex)
{