private static Autofac.IContainer BuildContainer() { var builder = new Autofac.Builder.ContainerBuilder(); builder.Register<Factory.IComment>(delegate(string author, string content) { return new Comment(author, content); }); builder.Register<Factory.IPosting>(ctx => delegate(string title, string author, string content) { return new Posting(title, author, content, ctx.Resolve<Factory.IComment>()); }); builder.Register<Factory.IBlog>(ctx => delegate(string title, string description) { return new Blog(title, description, ctx.Resolve<Factory.IPosting>()); }); builder.Register(typeof(Blog)).As<Interfaces.IBlog>(); return builder.Build(); }
public void AddToContainer(ContainerAdder adder) { var containerBuilder = new Autofac.Builder.ContainerBuilder(); adder.Invoke(containerBuilder); containerBuilder.Build(_container); }