replace v6 with experimental v7 code

This commit is contained in:
stax76
2023-10-24 11:17:45 +02:00
parent fb27bb8727
commit 5706d7b66d
212 changed files with 15014 additions and 12173 deletions

View File

@@ -0,0 +1,41 @@

using System.Reflection;
using MpvNet.ExtensionMethod;
namespace MpvNet;
public class ExtensionLoader
{
public event Action<Exception>? UnhandledException;
readonly List<object?> _refs = new();
void LoadDll(string path)
{
if (!File.Exists(path))
return;
try
{
Assembly asm = Assembly.LoadFile(path);
var type = asm.GetTypes().Where(typeof(IExtension).IsAssignableFrom).First();
_refs.Add(Activator.CreateInstance(type));
}
catch (Exception ex)
{
UnhandledException?.Invoke(ex);
}
}
public void LoadFolder(string path)
{
if (Directory.Exists(path))
foreach (string dir in Directory.GetDirectories(path))
LoadDll(dir.AddSep() + Path.GetFileName(dir) + ".dll");
}
}
public interface IExtension
{
}