-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
52 lines (45 loc) · 1.92 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
44
45
46
47
48
49
50
51
52
using Blackbaud.HeadlessDataSync.Services;
using Blackbaud.HeadlessDataSync.Services.DataSync;
using Blackbaud.HeadlessDataSync.Services.SkyApi;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Configuration;
using System.IO;
namespace Blackbaud.HeadlessDataSync
{
class Program
{
public static IConfigurationRoot Configuration;
private const string ENV_VAR_PREFIX = "BBHeadlessDataSync_";
static void Main(string[] args)
{
Configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables(ENV_VAR_PREFIX)
.Build();
// set up DI
var services = new ServiceCollection()
.AddLogging(builder => {
builder.AddConfiguration(Configuration.GetSection("Logging"));
builder.AddConsole();
})
.AddOptions()
.Configure<AppSettings>(options => Configuration.GetSection("AppSettings").Bind(options))
.AddSingleton<IAuthenticationService, AuthenticationService>()
.AddSingleton<IConstituentsService, ConstituentsService>()
.AddSingleton<IDataStorageService, DataStorageService>()
.AddSingleton<IDataSyncService, DataSyncService>()
.AddTransient<SyncApp, SyncApp>();
// Add data protection
services.AddDataProtection();
var serviceProvider = services.BuildServiceProvider();
// configure console logging
serviceProvider.GetService<ILoggerFactory>()
.CreateLogger<Program>();
// run data sync
serviceProvider.GetService<SyncApp>().Run(args);
}
}
}