【发布时间】:2020-11-05 07:28:52
【问题描述】:
我有一个 ASP.Net Core 3.1 应用程序,并且我有许多通过 MEF 加载的 plugins。简化的界面如下所示:
public interface IImportPlugin
{
string Name { get; }
string Category { get; }
string Title { get; }
string Description { get; }
}
插件类可能如下所示:
[Export(typeof(IImportPlugin))]
public sealed class ImportCustomers : IImportPlugin
{
private ICustomerService customerService;
//Other services...
[ImportingConstructor]
public ImportCustomers()
: base()
{
//Set properties
}
}
如何将服务实例注入插件?
【问题讨论】:
-
你用的是哪个版本的mef?
-
@sayahimad 4.7.0
-
我需要 MEF 版本而不是 .Net Framework
-
@sayahimad 在哪里可以找到?
标签: c# asp.net-core mef