remove LoadOwnPlugins and listener for AppDomain.AssemblyLoad
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>2.10.8</Version>
|
<Version>2.11.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Pilz.Text;
|
using System.Reflection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace Pilz.Plugins;
|
namespace Pilz.Plugins;
|
||||||
|
|
||||||
@@ -17,11 +16,6 @@ public class PluginManager<TPluginInterface, TPluginRuntimeInfo> where TPluginIn
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual IEnumerable<TPluginRuntimeInfo> LoadedPlugins => loadedPlugins.AsReadOnly();
|
public virtual IEnumerable<TPluginRuntimeInfo> LoadedPlugins => loadedPlugins.AsReadOnly();
|
||||||
|
|
||||||
protected void OnCurrentAppDomainAssemblyLoad(object? sender, AssemblyLoadEventArgs args)
|
|
||||||
{
|
|
||||||
LoadPlugins(args.LoadedAssembly, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads assembly from the given file paths and then loads the plugins from the assemblies.
|
/// Loads assembly from the given file paths and then loads the plugins from the assemblies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -54,39 +48,6 @@ public class PluginManager<TPluginInterface, TPluginRuntimeInfo> where TPluginIn
|
|||||||
return results;
|
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>
|
/// <summary>
|
||||||
/// Loads an assembly from the given file path and then loads plugins from the assembly.
|
/// Loads an assembly from the given file path and then loads plugins from the assembly.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user