How to register into ContainerBuilder
a MyComponent
class which has a construtor that accept two parameters?
Example:
public class MyComponent
{
public MyComponent(ILogger logger, IConfigReader reader) { /* ... */ }
}
Its not quite from autofac documentation if multipling the RegisterType
will work:
var builder = new ContainerBuilder();
builder.RegisterType<MyComponent>();
builder.RegisterType<ConsoleLogger>().As<ILogger>();
builder.RegisterType<ConsoleConfigReader>().As<IConfigReader>();
Is adding the builder.RegisterType<ConsoleConfigReader>().As<IConfigReader>();
again after register the ILogger
type is legitimate?
Aucun commentaire:
Enregistrer un commentaire