-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
48 lines (43 loc) · 1.64 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
using AdobeBlockListConverter.Configs;
using AdobeBlockListConverter.Interfaces;
using AdobeBlockListConverter.Services;
using Microsoft.Extensions.DependencyInjection;
using Application = AdobeBlockListConverter.Applications.Application;
namespace AdobeBlockListConverter
{
public static class Program
{
public static async Task Main(string[] args)
{
try
{
var serviceProvider = ConfigureServices();
var app = serviceProvider.GetRequiredService<IApplication>();
await app.RunAsync(args);
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"\r\n未处理的异常:{ex.Message}");
Console.WriteLine(ex.StackTrace);
Console.ResetColor();
}
if (!(args.Length > 3 && args[3] == "-q"))
{
Console.WriteLine($"\r\n按任意键退出。");
Console.ReadKey();
}
}
private static ServiceProvider ConfigureServices()
{
var services = new ServiceCollection();
services.AddSingleton<IAppConfig, AppConfig>();
services.AddTransient<IFileService, FileService>();
services.AddTransient<INetworkService, NetworkService>();
services.AddTransient<IDataProcessor, DataProcessor>();
services.AddTransient<IUserInterface, ConsoleUserInterface>();
services.AddTransient<IApplication, Application>();
return services.BuildServiceProvider();
}
}
}