public IDependencyResolver Methods() { var container = new Container(); container.Register <IAuthorRepository>(() => { var rep = new AuthorRepositoryMtd(); rep.SetDependencies(container.GetInstance <ILog>(), container.GetInstance <IBookRepository>()); return(rep); }); container.Register <IBookRepository>(() => { var rep = new BookRepositoryMtd(); rep.SetLog(container.GetInstance <ILog>()); return(rep); }); container.Register <ILog>(() => new ConsoleLog()); return(new DependencyResolver(container)); }
public IDependencyResolver Methods() { var builder = new ContainerBuilder(); builder.Register(c => { var rep = new AuthorRepositoryMtd(); rep.SetDependencies(c.Resolve <ILog>(), c.Resolve <IBookRepository>()); return(rep); }).As <IAuthorRepository>(); builder.Register(c => { var rep = new BookRepositoryMtd(); rep.SetLog(c.Resolve <ILog>()); return(rep); }).As <IBookRepository>(); builder.Register(c => new ConsoleLog()).As <ILog>(); var container = builder.Build(); return(new DependencyResolver(container)); }