-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathProgram.cs
45 lines (42 loc) · 1.56 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
using Akiled.Core;
using System;
using System.Security.Permissions;
using System.Threading.Tasks;
namespace Akiled
{
public static class Program
{
[STAThread]
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)]
public static void Main()
{
InitEnvironment();
while (true)
{
// \/ This \/ and this
if (!Console.IsInputRedirected && Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Enter)
{
Console.Write("Akiled Command> ");
string text = Console.ReadLine();
if (text.Length > 0)
{
ConsoleCommands.InvokeCommand(text.Split(' ', StringSplitOptions.None)[0]);
}
}
}
}
[MTAThread]
public static async Task InitEnvironment()
{
Console.ForegroundColor = ConsoleColor.White;
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
await AkiledEnvironment.Initialize().ConfigureAwait(true);
}
private static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
Logging.DisablePrimaryWriting(true);
Logging.LogCriticalException("SYSTEM CRITICAL EXCEPTION: " + ((Exception)args.ExceptionObject).ToString());
AkiledEnvironment.PreformShutDown(true);
}
}
}