0

I am using Autofac for IoC

Here is the constructor of my class which takes IProcessor and size as parameters

public GatewayClient(IProcessor processor,
      int size)
{
   _size = size;
   _processor = processor;
}

Here is my container initiator class, whose responsibility is to register the dependencies.

var size = Convert.ToInt32(configuration.GetValue<string>("Settings:SizeInKb"));

builder.RegisterType<Processor>().As<IProcessor>().SingleInstance();
builder.Register(c => new GatewayClient(size)).As<IGatewayClient>().SingleInstance();

The error says as follow

There is no argument given that corresponds to the required formal parameter 'processor' of 'GatewayClient(IProcessor, int)' MyProject.GatewayService C:\work\GatewayService\ContainerInitiator.cs

Question is, How do I pass the size to the constructor? it shall be taken care of by autofac right?

kudlatiger
  • 3,028
  • 8
  • 48
  • 98

0 Answers0