mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Implemented plugin reloading
This commit is contained in:
1 parent
adac6f4f8c
commit
3db4aab8bc
3 files changed
+37
-18
No files matched your search
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Artemis.Plugins.Interfaces;
|
||||
using Artemis.Plugins.Models;
|
||||
|
||||
namespace Artemis.Core.Events
|
||||
{
|
||||
@@ -9,11 +9,11 @@ namespace Artemis.Core.Events
|
||||
{
|
||||
}
|
||||
|
||||
public PluginEventArgs(IPlugin plugin)
|
||||
public PluginEventArgs(PluginInfo pluginInfo)
|
||||
{
|
||||
Plugin = plugin;
|
||||
PluginInfo = pluginInfo;
|
||||
}
|
||||
|
||||
public IPlugin Plugin { get; }
|
||||
public PluginInfo PluginInfo { get; }
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
// Empty the list of plugins
|
||||
foreach (var pluginInfo in _plugins)
|
||||
pluginInfo.Dispose();
|
||||
pluginInfo.UnloadPlugin();
|
||||
_plugins.Clear();
|
||||
|
||||
// Iterate all plugin folders and load each plugin
|
||||
@@ -52,17 +52,24 @@ namespace Artemis.Core.Services
|
||||
/// <inheritdoc />
|
||||
public async Task ReloadPlugin(PluginInfo pluginInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
pluginInfo.UnloadPlugin();
|
||||
await pluginInfo.CompilePlugin(_kernel);
|
||||
|
||||
OnPluginReloaded(new PluginEventArgs(pluginInfo));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IModuleViewModel> GetModuleViewModel(PluginInfo pluginInfo)
|
||||
{
|
||||
return pluginInfo.GetModuleViewModel(_kernel);
|
||||
return await Task.Run(() => pluginInfo.GetModuleViewModel(_kernel));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Empty the list of plugins
|
||||
foreach (var pluginInfo in _plugins)
|
||||
pluginInfo.UnloadPlugin();
|
||||
_plugins.Clear();
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
Reference in new issue
Block a user