remove LoadOwnPlugins and listener for AppDomain.AssemblyLoad
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Pilz.Text;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pilz.Plugins;
|
||||
|
||||
@@ -17,11 +16,6 @@ public class PluginManager<TPluginInterface, TPluginRuntimeInfo> where TPluginIn
|
||||
/// </summary>
|
||||
public virtual IEnumerable<TPluginRuntimeInfo> LoadedPlugins => loadedPlugins.AsReadOnly();
|
||||
|
||||
protected void OnCurrentAppDomainAssemblyLoad(object? sender, AssemblyLoadEventArgs args)
|
||||
{
|
||||
LoadPlugins(args.LoadedAssembly, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads assembly from the given file paths and then loads the plugins from the assemblies.
|
||||
/// </summary>
|
||||
@@ -54,39 +48,6 @@ public class PluginManager<TPluginInterface, TPluginRuntimeInfo> where TPluginIn
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads plugins from already loaded assemblies for the current <see cref="AppDomain.CurrentDomain"/>.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual IEnumerable<PluginLoadInfo<TPluginInterface, TPluginRuntimeInfo>> LoadOwnPlugins(object?[]? parameters, string? whitelist)
|
||||
{
|
||||
return LoadOwnPlugins(false, parameters, whitelist);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads plugins from already loaded assemblies for the current <see cref="AppDomain.CurrentDomain"/>.
|
||||
/// </summary>
|
||||
/// <param name="listenAssemblyLoadContext">Do also load plugins from all yet not loaded assemblies by listening the event <see cref="AppDomain.AssemblyLoad"/></param>
|
||||
/// <param name="whitelist"></param>>.
|
||||
/// <param name="parameters"></param>>.
|
||||
/// <returns></returns>
|
||||
public virtual IEnumerable<PluginLoadInfo<TPluginInterface, TPluginRuntimeInfo>> LoadOwnPlugins(bool listenAssemblyLoadContext, object?[]? parameters, string? whitelist)
|
||||
{
|
||||
var results = new List<PluginLoadInfo<TPluginInterface, TPluginRuntimeInfo>>();
|
||||
|
||||
if (listenAssemblyLoadContext)
|
||||
AppDomain.CurrentDomain.AssemblyLoad += OnCurrentAppDomainAssemblyLoad;
|
||||
|
||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies().AsEnumerable();
|
||||
if (!string.IsNullOrWhiteSpace(whitelist))
|
||||
assemblies = assemblies.Where(n => LikeOperator.IsLike(n.GetName().Name, whitelist));
|
||||
|
||||
foreach (var assembly in assemblies)
|
||||
results.Add(LoadPlugins(assembly, parameters));
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads an assembly from the given file path and then loads plugins from the assembly.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user