NucuCar/NucuCar.Sensors/Program.cs

38 lines
1.2 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
2019-11-09 13:34:49 +00:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NucuCar.Sensors.EnvironmentSensor;
using NucuCar.Sensors.Telemetry;
2019-11-09 13:34:49 +00:00
namespace NucuCar.Sensors
2019-11-09 13:34:49 +00:00
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
2019-11-09 13:34:49 +00:00
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
// Transient
services.AddTransient<TelemetryConfig>();
services.AddTransient<Bme680Config>();
// Singletons
services.AddSingleton<SensorTelemetry>();
services.AddSingleton<Bme680Sensor>();
// Workers
services.AddHostedService<TelemetryWorker>();
services.AddHostedService<Bme680Worker>();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<GrpcStartup>();
});
2019-11-09 13:34:49 +00:00
}
}