Using specific instance of one object when
This commit is contained in:
@ -70,10 +70,13 @@ namespace AutoFacSamles
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
builder.RegisterType<ConsoleLog>().As<ILog>();
|
//builder.RegisterType<ConsoleLog>().As<ILog>();
|
||||||
|
var log = new ConsoleLog();
|
||||||
|
builder.RegisterInstance(log).As<ILog>(); //val av redan instantierat objekt
|
||||||
|
|
||||||
builder.RegisterType<Engine>();
|
builder.RegisterType<Engine>();
|
||||||
builder.RegisterType<Car>()
|
builder.RegisterType<Car>()
|
||||||
.UsingConstructor(typeof(Engine));
|
.UsingConstructor(typeof(Engine)); //val av contructor
|
||||||
|
|
||||||
IContainer container = builder.Build();
|
IContainer container = builder.Build();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user