public static void AddPersistenceServices(this IServiceCollection services, IAppWeatherConfig appConfig) { services.AddAutoMapper(); services.AddDbContext <AppWeatherDbtContext>(optionsBuilder => { if (appConfig.IsTesting) { optionsBuilder.UseLazyLoadingProxies() .UseInMemoryDatabase("AppWeatherTestDb"); } else { // production Db optionsBuilder.UseLazyLoadingProxies() .UseSqlServer(appConfig.DataConnectionString, options => { options.MigrationsAssembly("AppWeather.Api"); }); } }); }
public static void RegisterExternalServicesDependencies(this ContainerBuilder builder, IAppWeatherConfig appWeatherConfig) { builder .RegisterType <GooglePlacesApiService>() .As <IGooglePlacesApiService>() .InstancePerLifetimeScope(); builder .RegisterInstance(new GooglePlacesApiConfiguration(appWeatherConfig.Bindings)) .As <IGooglePlacesApiConfiguration>() .SingleInstance(); builder .RegisterType <OpenWeatherMapApiService>() .As <IOpenWeatherMapApiService>() .InstancePerLifetimeScope(); builder .RegisterInstance(new OpenWeatherMapApiConfiguration(appWeatherConfig.Bindings)) .As <IOpenWeatherMapConfiguration>() .SingleInstance(); }
public Startup(IConfiguration configuration) { _configuration = new AppWeatherConfig(configuration); }
public static void RegisterApiDependencies(this ContainerBuilder builder, IAppWeatherConfig appWeatherConfig) { builder.RegisterInstance(appWeatherConfig).As <IAppWeatherConfig>().SingleInstance(); }