我正在使用Autofac进行IoC
这是我的类的构造函数,它以IProcessor
和size
作为参数
public GatewayClient(IProcessor processor,
int size)
{
_size = size;
_processor = processor;
}
这是我的容器启动器类,其职责是注册依赖项。
var size = Convert.ToInt32(configuration.GetValue<string>("Settings:SizeInKb"));
builder.RegisterType<Processor>().As<IProcessor>().SingleInstance();
builder.Register(c => new GatewayClient(size)).As<IGatewayClient>().SingleInstance();
错误说明如下
没有给出与“ GatewayClient(IProcessor,int)” MyProject.GatewayService C:\ work \ GatewayService \ ContainerInitiator.cs所需的形式参数“ processor”相对应的参数。
问题是,如何将size
传递给构造函数? autofac
会照顾好吗?