Choosing constructor when several is defined
This commit is contained in:
@ -46,7 +46,13 @@ namespace AutoFacSamles
|
|||||||
private Engine engine;
|
private Engine engine;
|
||||||
private ILog log;
|
private ILog log;
|
||||||
|
|
||||||
public Car(Engine engine,ILog log)
|
public Car(Engine engine)
|
||||||
|
{
|
||||||
|
this.engine = engine;
|
||||||
|
this.log = new EmailLog();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Car(Engine engine, ILog log)
|
||||||
{
|
{
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.log = log;
|
this.log = log;
|
||||||
@ -64,9 +70,10 @@ namespace AutoFacSamles
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
builder.RegisterType<EmailLog>().As<ILog>();
|
builder.RegisterType<ConsoleLog>().As<ILog>();
|
||||||
builder.RegisterType<Engine>();
|
builder.RegisterType<Engine>();
|
||||||
builder.RegisterType<Car>();
|
builder.RegisterType<Car>()
|
||||||
|
.UsingConstructor(typeof(Engine));
|
||||||
|
|
||||||
IContainer container = builder.Build();
|
IContainer container = builder.Build();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user