Interface IPluginService
Namespace: Void.Proxy.Api.Plugins
Assembly: Void.Proxy.Api.dll
Manages the lifecycle of proxy plugins, including discovery, loading, and unloading
of plugin containers backed by isolated
public interface IPluginServiceExtension Methods
PluginExtensions.GetPluginFromType<T>(IPluginService), PluginExtensions.GetPluginFromType(IPluginService, Type), PluginExtensions.TryGetPluginFromType(IPluginService, Type, out IPlugin)
Properties
All
Gets all plugin instances currently active across all loaded containers.
IEnumerable<IPlugin> All { get; }Property Value
Containers
Gets the names of all currently loaded plugin containers.
IEnumerable<string> Containers { get; }Property Value
Methods
GetPlugins(Assembly)
Returns all non-abstract types in assembly that implement
IEnumerable<Type> GetPlugins(Assembly assembly)Parameters
assembly Assembly
The assembly to scan.
Returns
The discovered
LoadContainer(string, Stream, bool)
Reads an assembly from stream into an isolated load context,
discovers all non-abstract
IEnumerable<Type> LoadContainer(string name, Stream stream, bool ignoreEmpty = false)Parameters
name string
A label used to identify the container in logs and the
stream Stream
A stream containing the assembly bytes to load.
ignoreEmpty bool
When true, logs a trace-level message instead of a warning
when the assembly contains no
Returns
The non-abstract types that implement
LoadDirectoryPluginsAsync(string, CancellationToken)
Loads all .dll files found in path as plugin containers.
Creates the directory when it does not already exist.
ValueTask LoadDirectoryPluginsAsync(string path = "plugins", CancellationToken cancellationToken = default)Parameters
path string
Relative or absolute path to the plugins directory. Defaults to “plugins”.
cancellationToken CancellationToken
A token to cancel the operation.
Returns
LoadEmbeddedPluginsAsync(CancellationToken)
Loads plugins embedded as manifest resources in the executing assembly.
Resources whose names contain Plugins are treated as plugin assemblies.
ValueTask LoadEmbeddedPluginsAsync(CancellationToken cancellationToken = default)Parameters
cancellationToken CancellationToken
A token to cancel the operation.
Returns
LoadEnvironmentPluginsAsync(CancellationToken)
Loads plugins specified via the —plugin/-p command-line arguments
or the VOID_PLUGINS environment variable.
Each entry may be a local file path, a directory path, or an HTTP/HTTPS URL.
ValueTask LoadEnvironmentPluginsAsync(CancellationToken cancellationToken = default)Parameters
cancellationToken CancellationToken
A token to cancel the operation.
Returns
LoadPluginAsync(Type, CancellationToken)
Instantiates a single plugin type within its existing container, fires PluginLoadingEvent and PluginLoadedEvent, and registers the plugin.
ValueTask LoadPluginAsync(Type pluginType, CancellationToken cancellationToken = default)Parameters
pluginType Type
The concrete type implementing
cancellationToken CancellationToken
A token to cancel the operation.
Returns
Exceptions
Thrown when no container is found for pluginType’s assembly.
LoadPluginsAsync(string, CancellationToken)
Sequentially loads environment plugins (from command-line arguments and environment variables),
embedded plugins, and directory plugins from path.
ValueTask LoadPluginsAsync(string path = "plugins", CancellationToken cancellationToken = default)Parameters
path string
Relative or absolute path to the directory scanned for plugin .dll files. Defaults to “plugins”.
cancellationToken CancellationToken
A token to cancel the operation.
Returns
LoadPluginsAsync(IEnumerable<Type>, CancellationToken)
Instantiates and registers each of the supplied plugin types as live plugins.
Types implementing
ValueTask LoadPluginsAsync(IEnumerable<Type> plugins, CancellationToken cancellationToken = default)Parameters
plugins IEnumerable<Type>
The plugin types to load.
cancellationToken CancellationToken
A token to cancel the operation.
Returns
UnloadContainerAsync(string, CancellationToken)
Fires PluginUnloadingEvent and PluginUnloadedEvent for every plugin in the named
container, cancels the container’s cancellation token, initiates assembly unload, and then forces
garbage collection until the weak reference is collected or a 10-second timeout expires.
ValueTask UnloadContainerAsync(string name, CancellationToken cancellationToken = default)Parameters
name string
The name of the container to unload, as returned by
cancellationToken CancellationToken
A token to cancel the operation.
Returns
Exceptions
Thrown when the container is not found, is already unloaded, or refuses to unload within the timeout.
UnloadContainersAsync(CancellationToken)
Unloads all active plugin containers, firing unload events for every plugin in each container.
ValueTask UnloadContainersAsync(CancellationToken cancellationToken = default)Parameters
cancellationToken CancellationToken
A token to cancel the operation.