mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-04-05 17:39:39 -04:00
Merge pull request #9 from fredjk-gh/NotifierPluginManagerFixes
Fixes to PluginManager for proper Notifier plugin handling
This commit is contained in:
commit
d51cc5ffa9
@ -59,6 +59,15 @@ namespace Observatory.PluginManagement
|
|||||||
LoadSettings(plugin);
|
LoadSettings(plugin);
|
||||||
plugin.Load(core);
|
plugin.Load(core);
|
||||||
}
|
}
|
||||||
|
foreach (var plugin in notifyPlugins.Select(p => p.plugin))
|
||||||
|
{
|
||||||
|
// Notifiers which are also workers need not be loaded again (they are the same instance).
|
||||||
|
if (!plugin.GetType().IsAssignableTo(typeof(IObservatoryWorker)))
|
||||||
|
{
|
||||||
|
LoadSettings(plugin);
|
||||||
|
plugin.Load(core);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
core.Notification += pluginHandler.OnNotificationEvent;
|
core.Notification += pluginHandler.OnNotificationEvent;
|
||||||
}
|
}
|
||||||
@ -228,10 +237,18 @@ namespace Observatory.PluginManagement
|
|||||||
ConstructorInfo constructor = worker.GetConstructor(Array.Empty<Type>());
|
ConstructorInfo constructor = worker.GetConstructor(Array.Empty<Type>());
|
||||||
object instance = constructor.Invoke(Array.Empty<object>());
|
object instance = constructor.Invoke(Array.Empty<object>());
|
||||||
workers.Add((instance as IObservatoryWorker, PluginStatus.Signed));
|
workers.Add((instance as IObservatoryWorker, PluginStatus.Signed));
|
||||||
|
if (instance is IObservatoryNotifier)
|
||||||
|
{
|
||||||
|
// This is also a notifier; add to the notifier list as well, so the work and notifier are
|
||||||
|
// the same instance and can share state.
|
||||||
|
notifiers.Add((instance as IObservatoryNotifier, PluginStatus.Signed));
|
||||||
|
}
|
||||||
pluginCount++;
|
pluginCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var notifyTypes = types.Where(t => t.IsAssignableTo(typeof(IObservatoryNotifier)));
|
// Filter out items which are also workers as we've already created them above.
|
||||||
|
var notifyTypes = types.Where(t =>
|
||||||
|
t.IsAssignableTo(typeof(IObservatoryNotifier)) && !t.IsAssignableTo(typeof(IObservatoryWorker)));
|
||||||
foreach (var notifier in notifyTypes)
|
foreach (var notifier in notifyTypes)
|
||||||
{
|
{
|
||||||
ConstructorInfo constructor = notifier.GetConstructor(Array.Empty<Type>());
|
ConstructorInfo constructor = notifier.GetConstructor(Array.Empty<Type>());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user