Work Modules
This commit is contained in:
@@ -1,19 +1,47 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using VisionAsist.SDK;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using VisionAsist.SDK;
|
||||
using System.Linq;
|
||||
namespace VisionAsist.Models;
|
||||
|
||||
|
||||
|
||||
|
||||
public class Core
|
||||
{
|
||||
public static Dictionary<string, IModule> _loadedModules = new();
|
||||
public static TrigerCore triger = new();
|
||||
public static string TextAsist;
|
||||
static string Plugin = Path.Combine(AppContext.BaseDirectory, "Modules");
|
||||
static Core()
|
||||
{
|
||||
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
||||
Console.InputEncoding = System.Text.Encoding.UTF8;
|
||||
string[] folderNames = new DirectoryInfo(Plugin)
|
||||
.GetDirectories()
|
||||
.Select(d => d.Name)
|
||||
.ToArray();
|
||||
foreach (string folderName in folderNames)
|
||||
{
|
||||
string mpn = Path.Combine(Plugin, folderName, "Module.dll");
|
||||
if (File.Exists(mpn))
|
||||
{
|
||||
Assembly assembly = Assembly.LoadFrom(mpn);
|
||||
var type = assembly.GetTypes().FirstOrDefault(t =>
|
||||
typeof(IModule).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract);
|
||||
if (type != null)
|
||||
{
|
||||
var module = (IModule)Activator.CreateInstance(type)!;
|
||||
Core._loadedModules.Add(module.Name, module);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static void StartListing()
|
||||
|
||||
Reference in New Issue
Block a user