-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.cs
33 lines (30 loc) · 1.07 KB
/
Config.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
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
namespace WebCrawlerCore
{
public class Config
{
public Config(string[] args)
{
var inMemory = new Dictionary<string, string>
{
{"site", "https://www.google.co.uk"},
{"output:folder", "reports" },
};
var configBuilder = new ConfigurationBuilder()
.AddInMemoryCollection(inMemory)
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("checksettings.json", true)
.AddCommandLine(args)
.AddEnvironmentVariables();
var configuration = configBuilder.Build();
Site = configuration["site"];
Output = configuration.GetSection("output").Get<OutputSettings>();
ConfigurationRoot = configuration;
}
public OutputSettings Output { get; set; }
public string Site { get; set; }
public IConfigurationRoot ConfigurationRoot { get; set; }
}
}