我正在使用autofac 3(最新版本)
如何在Type在构建器中注册后进行属性注入。
builder.RegisterType(customType);
现在,我想将属性信息注入customType。
我不想在初始化的时候这样做。
有办法吗?
我希望在两个步骤中完成:步骤- 1:注册组件
步骤2:提取已注册的组件,然后将属性值对注入到该注册中。
有可能用自动发卡吗?
发布于 2013-06-19 10:33:14
如果希望在注册时而不是初始化时设置注入,请使用WithProperty或WithProperties方法。
ie builder.RegisterType(customType).WithProperty("PropertyName", "value");
https://stackoverflow.com/questions/17188883
复制相似问题