[英]Can a IOC Container replace CreateInstance reflection code?
我在这个问题中显示了类似的设置,并想知道我是否可以替换所有使用反射的代码来查找某种类型的插件,然后使用IOC容器对其执行CreateInstance
,其中包含:
builder.RegisterAssemblyTypes(typeof(MyType).Assembly)
是的,你可以这样做:
builder.RegisterAssemblyTypes(typeof(MyType).Assembly).AsImplementedInterfaces();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.