// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var geoRestSvc = new RestRequestor <GeoResponse>(); var weatherRestSvc = new RestRequestor <ForecastResponse>(); var parser = new GeoQueryParser(); var geoDispatchSvc = new GeocodioQueryDispatchService(geoRestSvc); var weatherDispatchSvc = new DarkskyQueryDispatchService(weatherRestSvc); services.AddMvc(); services.AddSingleton <IGeoQueryService>(new GeocodioQueryService(parser, geoDispatchSvc)); services.AddSingleton <IWeatherQueryService>(new DarkskyQueryService(weatherDispatchSvc)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var geoRestSvc = new RestRequestor <GeoResponse>(); var weatherRestSvc = new RestRequestor <ForecastResponse>(); var parser = new GeoQueryParser(); var geoDispatchSvc = new GeocodioQueryDispatchService(geoRestSvc); var weatherDispatchSvc = new DarkskyQueryDispatchService(weatherRestSvc); // Add framework services. services.AddMvc(); // Add custom services services.AddEnyimMemcached(options => Configuration.GetSection("enyimMemcached").Bind(options)); // this was a dumb way to do it... var sp = services.BuildServiceProvider(); var memcachedService = sp.GetService <IMemcachedClient>(); services.AddSingleton <IGeoQueryService>(new GeocodioQueryService(parser, geoDispatchSvc, memcachedService)); services.AddSingleton <IWeatherQueryService>(new DarkskyQueryService(weatherDispatchSvc, memcachedService)); }