Exemplo n.º 1
0
 public Worker(ILogger <Worker> logger, ServiceAppSettings appSettings, JsonSerializerOptions jsonSerializerOptions, MyContext context)
 {
     _logger                = logger;
     _appSettings           = appSettings;
     _jsonSerializerOptions = jsonSerializerOptions;
     _context               = context;
 }
Exemplo n.º 2
0
        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>();
        });
Exemplo n.º 3
0
 public DefaultServiceWeatherRequestBuilder(ServiceAppSettings settings)
 {
     _appSettings = settings;
 }
Exemplo n.º 4
0
 public ServiceWeatherRequestBuilder(ServiceAppSettings settings, Location location)
 {
     _appSettings = settings;
     _location    = location;
 }