public Worker(ILogger <Worker> logger, ServiceAppSettings appSettings, JsonSerializerOptions jsonSerializerOptions, MyContext context) { _logger = logger; _appSettings = appSettings; _jsonSerializerOptions = jsonSerializerOptions; _context = context; }
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureServices((hostContext, services) => { ServiceAppSettings appSettings = hostContext.Configuration.ExtractWeatherSettings(); JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true, PropertyNameCaseInsensitive = true, DictionaryKeyPolicy = JsonNamingPolicy.CamelCase, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; services.AddDbContext <MyContext>(options => { options.UseNpgsql(appSettings.ConnectionStrings["Default"] /*, npgOptions => npgOptions.MigrationsAssembly("MyWeatherService")*/); }, ServiceLifetime.Singleton); services.AddSingleton(appSettings); services.AddSingleton(jsonSerializerOptions); services.AddHostedService <Worker>(); });
public DefaultServiceWeatherRequestBuilder(ServiceAppSettings settings) { _appSettings = settings; }
public ServiceWeatherRequestBuilder(ServiceAppSettings settings, Location location) { _appSettings = settings; _location = location; }