Implemented plugin reloading

This commit is contained in:
SpoinkyNL committed 2018-03-05 23:44:39 +01:00
1 parent adac6f4f8c
commit 3db4aab8bc
3 files changed
+37 -18

No files matched your search

+4 -4
View File
@@ -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; }
}
}
+10 -3
View File
@@ -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