forked from dfederm/GenericHostConsoleApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
30 lines (28 loc) · 1.01 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
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace GenericHostConsoleApp
{
internal sealed class Program
{
private static async Task Main(string[] args)
{
await Host.CreateDefaultBuilder(args)
.UseContentRoot(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
.ConfigureLogging(logging =>
{
// Add any 3rd party loggers like NLog or Serilog
})
.ConfigureServices((hostContext, services) =>
{
services
.AddHostedService<ConsoleHostedService>()
.AddSingleton<IWeatherService, WeatherService>();
services.AddOptions<WeatherSettings>().Bind(hostContext.Configuration.GetSection("Weather"));
})
.RunConsoleAsync();
}
}
}