DotNetDynamicInjector
1.0.0
外部項目DLL的動態依賴注射器
動態引用外部DLL,而無需將它們添加到項目中。將您的項目留下較低的依賴性,並根據您的業務規則或數據庫參數允許特定的DLL。
資訊
| 代碼質量 | 建造 | nuget | 貢獻者 |
|---|---|---|---|
平台支持
dotnet.dynamicinjector是.NET標準2.0庫。
使用DynamicIndoctor
默認情況下應引用的DLL必須在編譯的項目文件夾中
在ASP.NET Core Project的啟動中使用服務配置
services . RegisterDynamicDependencies ( ioCConfiguration ) ;IOCCONFIGURATION包含您依賴注入的配置。可以僅指定您要引用的名稱空間,忽略項目中的其他名稱空間
var ioCConfiguration = new IoCConfiguration ( )
{
AllowedInterfaceNamespaces =
new List < string > { "Mynamespance1" , "Mynamespance2" }
} ;Iocrole配置您要自動注入的DLL和依賴類型
var role = new IoCRole
{
Dll = "MyProject.dll" , //DLL name
Implementation = "My Implementation" , // Implementation name, can be used for a control if you use several projects and wanted to separate them
Priority = 1 , // Priority that the dll should be loaded
LifeTime = LifeTime . SCOPED , // Lifetime of your addiction injection
Name = "My client business rule x" //Dependency name. It is used only for identification
} ;
ioCConfiguration . Roles . Add ( role ) ;樣品即將到來..