Fixed Internal Actions to refresh after external actions are loaded

This commit is contained in:
2023-08-15 16:17:32 +03:00
parent ee527bb36f
commit 6315d13d18
6 changed files with 59 additions and 16 deletions

View File

@@ -18,23 +18,31 @@ public class InternalActionManager
public async Task Initialize()
{
loader.ActionLoadedEvent += OnActionLoaded;
//loader.ActionLoadedEvent += OnActionLoaded;
var m_actions = await loader.Load();
if (m_actions == null) return;
foreach (var action in m_actions)
Actions.Add(action.ActionName, action);
}
private void OnActionLoaded(string name, string typeName, bool success, Exception? e)
{
if (!success)
{
Config.Logger.Error(e);
return;
Actions.TryAdd(action.ActionName, action);
}
Config.Logger.Log($"Action {name} loaded successfully", LogLevel.INFO, true);
}
public async Task Refresh()
{
Actions.Clear();
await Initialize();
}
// private void OnActionLoaded(string name, string typeName, bool success, Exception? e)
// {
// if (!success)
// {
// Config.Logger.Error(e);
// return;
// }
//
// Config.Logger.Log($"Action {name} loaded successfully", LogLevel.INFO, true);
// }
public async Task<string> Execute(string actionName, params string[]? args)
{