diff --git a/AutoFacSamles/Program.cs b/AutoFacSamles/Program.cs index 60ed079..eea8a5b 100644 --- a/AutoFacSamles/Program.cs +++ b/AutoFacSamles/Program.cs @@ -29,6 +29,13 @@ namespace AutoFacSamles { private ILog log; private int id; + + public Engine(ILog log, int id) + { + this.log = log; + this.id = id; + } + public Engine(ILog log) { this.log = log; @@ -70,13 +77,13 @@ namespace AutoFacSamles static void Main(string[] args) { var builder = new ContainerBuilder(); - //builder.RegisterType().As(); - var log = new ConsoleLog(); - builder.RegisterInstance(log).As(); //val av redan instantierat objekt + builder.RegisterType().As(); - builder.RegisterType(); - builder.RegisterType() - .UsingConstructor(typeof(Engine)); //val av contructor + builder.Register( c => + new Engine(c.Resolve(), 123)); + + //builder.RegisterType(); + builder.RegisterType(); IContainer container = builder.Build();