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 ) ;样品即将到来..