separete parameters collection
This commit is contained in:
@@ -167,9 +167,6 @@ public class PluginManager<TPluginInterface, TPluginRuntimeInfo> where TPluginIn
|
||||
|
||||
protected virtual void LoadPlugin(PluginLoadInfo<TPluginInterface, TPluginRuntimeInfo> result, Type type, params object?[]? parameters)
|
||||
{
|
||||
if (parameters == null || parameters.Length == 0)
|
||||
parameters = DefaultParameters;
|
||||
|
||||
if (loadedPlugins.Any(n => n.Plugin != null && n.Plugin.GetType() == type))
|
||||
result.Status = PluginLoadStatus.AlreadyLoaded;
|
||||
else if (type.IsAssignableTo(typeof(TPluginInterface)))
|
||||
@@ -180,7 +177,7 @@ public class PluginManager<TPluginInterface, TPluginRuntimeInfo> where TPluginIn
|
||||
|
||||
try
|
||||
{
|
||||
if (Activator.CreateInstance(type, GetConstructorFlags(), null, parameters, null) is TPluginInterface plugin)
|
||||
if (Activator.CreateInstance(type, GetConstructorFlags(), null, GetParameters(type, parameters), null) is TPluginInterface plugin)
|
||||
{
|
||||
if (plugin is IPluginLateInitialization pluginLateInit)
|
||||
pluginLateInit.LateInit();
|
||||
@@ -200,6 +197,13 @@ public class PluginManager<TPluginInterface, TPluginRuntimeInfo> where TPluginIn
|
||||
result.Status = PluginLoadStatus.NoValidPlugin;
|
||||
}
|
||||
|
||||
protected virtual object?[]? GetParameters(Type type, object?[]? parameters)
|
||||
{
|
||||
if (parameters == null || parameters.Length == 0)
|
||||
return DefaultParameters;
|
||||
return parameters;
|
||||
}
|
||||
|
||||
protected virtual BindingFlags GetConstructorFlags()
|
||||
{
|
||||
return BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance;
|
||||
|
||||
Reference in New Issue
Block a user