-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (34 loc) · 1.12 KB
/
Copy pathProgram.cs
File metadata and controls
40 lines (34 loc) · 1.12 KB
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
using System;
using System.Net.Http;
using Interfaces;
using Microsoft.Extensions.DependencyInjection;
using Services;
using Weather.DependencyManager;
using Weather.Interfaces;
using Weather.Services;
namespace Weather
{
class Program
{
static void Main(string[] args)
{
// create service collection
var serviceCollection = new ServiceCollection();
ConfigureServices(serviceCollection);
// create service provider
var serviceProvider = serviceCollection.BuildServiceProvider();
// entry to run app
serviceProvider.GetService<App>().Run();
Console.ReadLine();
}
static void ConfigureServices(IServiceCollection serviceCollection)
{
// add services
var httpClient = new HttpClientWrapper(new HttpClientHandler { UseCookies = false });
serviceCollection.AddSingleton<IHttpClient>(httpClient);
serviceCollection.AddTransient<IWeatherFetcher, WeatherFetcher>();
// add app
serviceCollection.AddTransient<App>();
}
}
}