我已经非常努力地完成这项工作,但当我尝试从容器中解析IConfigReader
时,它说我还没有注册任何组件。我一遍又一遍地读完它。百思不得其解!
var builder = new ContainerBuilder();
builder.RegisterType<ConsoleLogger>().As<ILogger>();
var output = new StringWriter();
builder.RegisterInstance(output).As<TextWriter>();
builder.Register(c => new ConfigReader("mysection")).As<IConfigReader>();
var container = builder.Build();
using(var scope = container.BeginLifetimeScope())
{
var reader = container.Resolve<IConfigReader>();
}