// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddCors(c => { c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); }); services.AddTransient <IMessageBuilder <TodoItem, TodoItemResponse>, TodoItemResponseBuilder>(); services.AddTransient <ITodoItemsManager, TodoItemsManager>(); services.AddTransient <ITodoItemsDao, TodoItemsDao>(); services.AddDbContext <TodoContext>(opt => { opt.UseSqlServer(Configuration.GetConnectionString("TodoDb")); }); services.AddMvc(); // Wire up StructureMap var container = new Container(); container.Configure(config => { config.Populate(services); config.For <IServiceLocator>().Singleton().Use(new StructureMapServiceLocator(container)); }); var registrar = new StructureMapRegistrar(container); registrar.Register <BaseRegistry>(); return(new StructureMapServiceProvider(container)); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddCors(c => { c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); }); services.AddTransient <IMessageBuilder <VirtualCloset, VirtualClosetResponse>, VirtualClosetResponseBuilder>(); services.AddTransient <IVirtualClosetDao, VirtualClosetDao>(); services.AddTransient <ICategoryManager, CategoryManager>(); services.AddTransient <IVirtualClosetManager, VirtualClosetManager>(); services.AddDbContext <VirtualClosetContext>(opt => { opt.UseSqlServer(Configuration.GetConnectionString("VirtualClosetDb")); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var container = new Container(); container.Configure(config => { config.Populate(services); config.For <IServiceLocator>().Singleton().Use(new StructureMapServiceLocator(container)); }); var registrar = new StructureMapRegistrar(container); registrar.Register <BaseRegistry>(); return(new StructureMapServiceProvider(container)); }