-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
43 lines (38 loc) · 1.33 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using Microsoft.Extensions.Hosting;
using NissanConnectLib.Api;
namespace NissanConnectLib.Example;
internal class Program
{
static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddEnvironmentVariables();
config.AddCommandLine(args);
config.AddUserSecrets<Program>();
})
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole(options =>
{
options.FormatterName = nameof(CustomConsoleFormatter);
});
logging.AddConsoleFormatter<CustomConsoleFormatter, ConsoleFormatterOptions>();
})
.ConfigureServices((context, services) =>
{
var config = context.Configuration.Get<Configuration>() ??
new Configuration();
services.AddHostedService<NissanConnectHostedService>();
services.AddSingleton<Configuration>(config);
services.AddSingleton<NissanConnectClient>();
});
await host.Build().RunAsync();
}
}