-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
50 lines (44 loc) · 1.09 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
using Terminal.Gui;
namespace Cilurbo;
partial class Program {
static readonly List<string> assemblies_file_extensions = new () { ".dll", ".exe" };
static readonly List<string> lists_file_extensions = new () { ".list", ".lst" };
static int Main (string [] args)
{
try {
Application.Init ();
var rv = SetupUI (Application.Top);
if (rv == 0) {
foreach (var arg in args) {
Console.WriteLine ($"Loading {arg}");
LoadFile (arg);
}
}
Application.Run ();
Application.Shutdown ();
return rv;
} catch (Exception e) {
Console.WriteLine (e);
return 1;
}
}
static void LoadFile (string file)
{
if (!File.Exists (file)) {
// TODO error logging
return;
}
var ext = Path.GetExtension (file).ToLowerInvariant ();
if (assemblies_file_extensions.Contains (ext)) {
var pe = AssemblyResolver.Resolver.Load (file);
if (pe is not null) {
var node = metadata_tree.Add (pe);
metadata_tree.SelectedObject = node;
}
} else if (lists_file_extensions.Contains (ext)) {
foreach (var f in File.ReadLines (file)) {
LoadFile (f);
}
}
}
}