-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
63 lines (48 loc) · 2.38 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
53
54
55
56
57
58
59
60
61
62
63
using AdamServer.Core;
using AdamServer.Core.Mappings;
using AdamServer.Interfaces;
using AdamServer.Services.Common;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using Serilog.Core;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace AdamServer
{
internal class Program
{
static async Task Main(string[] args)
{
WebApplicationBuilder builder = WebApplication.CreateSlimBuilder(args);
builder.Configuration.Sources.Clear();
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
AppSettingsOptionsService options = new();
builder.Configuration.GetRequiredSection("AppSettingsOptions").Bind(options);
builder.Services.AddSingleton<IAppSettingsOptionsService>(options);
Logger mainLogger = new LoggerConfiguration()
.WriteTo.File("logs/log-.txt",
rollingInterval: RollingInterval.Day, retainedFileCountLimit: 10,
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}")
.CreateLogger();
builder.Services.AddLogging(s => s.AddSerilog(mainLogger, dispose: true));
/*Obsolete AuthenticationScheme*/
//builder.Services.AddAuthentication().AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>("", options => { });
builder.Services.AddSingleton<IWebApiHandlerService, WebApiHandlerService>();
/*if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
builder.Services.AddSingleton<IPythonCommandService, Services.Linux.PythonCommandService>();
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
builder.Services.AddSingleton<IPythonCommandService, Services.Windows.PythonCommandService>();
}*/
builder.Services.AddHostedService<FindMeService>();
builder.Services.AddSingleton<ITcpPythonStreamClientService, TcpPythonStreamClientService>();
var app = builder.Build();
PythonMapping.Map(app);
await app.RunAsync();
}
}
}