Skip to content

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 instances.

public interface IPluginService

Extension 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

IEnumerable<IPlugin>

Containers

Gets the names of all currently loaded plugin containers.

IEnumerable<string> Containers { get; }

Property Value

IEnumerable<string>

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

IEnumerable<Type>

The discovered implementation types.

LoadContainer(string, Stream, bool)

Reads an assembly from stream into an isolated load context, discovers all non-abstract implementations, and returns those types.

IEnumerable<Type> LoadContainer(string name, Stream stream, bool ignoreEmpty = false)

Parameters

name string

A label used to identify the container in logs and the list.

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 implementations.

Returns

IEnumerable<Type>

The non-abstract types that implement found in the loaded assembly.

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

ValueTask

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

ValueTask

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

ValueTask

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 to load.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

ValueTask

Exceptions

Exception

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

ValueTask

LoadPluginsAsync(IEnumerable<Type>, CancellationToken)

Instantiates and registers each of the supplied plugin types as live plugins. Types implementing are loaded before all other plugin types.

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

ValueTask

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

ValueTask

Exceptions

Exception

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.

Returns

ValueTask