-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (53 loc) · 2.03 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (53 loc) · 2.03 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.WindowsServices;
using Microsoft.AspNetCore.Server.HttpSys;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Diagnostics;
using System.IO;
namespace AnwesenheitsListeErweiterung {
/// <summary>
/// Klasse mit dem Eintrittspunkt.
/// </summary>
public class Program {
/// <summary>
/// Eintrittspunkt des Programms.
/// </summary>
/// <param name="args">Enthält die Kommandozeilenargumente.</param>
public static void Main(string[] args) {
try {
string contentRoot = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
Directory.SetCurrentDirectory(contentRoot);
IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(contentRoot)
.AddCommandLine(args)
.Build();
IWebHost host = new WebHostBuilder()
.UseContentRoot(contentRoot)
.UseConfiguration(configuration)
.ConfigureLogging(logging =>
logging.AddConsole())
.UseStartup<Startup>()
.UseHttpSys(options => {
options.Authentication.Schemes = AuthenticationSchemes.None;
options.Authentication.AllowAnonymous = true;
})
.Build();
if (Environment.UserInteractive) {
host.Run();
}
else {
host.RunAsService();
}
}
catch (Exception e) {
new LoggerFactory()
.AddConsole()
.CreateLogger<Program>()
.LogCritical(e.Message);
}
}
}
}