// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var config = new ServerConfig(); Configuration.Bind(config); var libraryContext = new RemoteLibraryContext(config.MongoDB); var booksRepository = new BooksRepository(libraryContext); var writersRepository = new WritersRepository(libraryContext); services.AddSingleton <IBooksRepository>(booksRepository); services.AddSingleton <IWritersRepository>(writersRepository); //services.AddSingleton<IActionContextAccessor, ActionContextAccessor>(); //services.AddScoped<IUrlHelper>(factory => //{ // var actionContext = factory.GetService<IActionContextAccessor>() // .ActionContext; // return new UrlHelper(actionContext); //}); services.AddControllers(); }
public WritersServiceImpl(WritersRepository writerRepository) { _writerRepository = writerRepository; }