Table of Contents

Class PluginSystem

Namespace
DotCompute.Plugins.Core
Assembly
DotCompute.Plugins.dll

Simplified plugin system for DotCompute.

public class PluginSystem : IDisposable
Inheritance
PluginSystem
Implements
Inherited Members
Extension Methods

Constructors

PluginSystem(PluginOptions, ILogger<PluginSystem>?)

Initializes a new instance of the PluginSystem class.

public PluginSystem(PluginOptions options, ILogger<PluginSystem>? logger = null)

Parameters

options PluginOptions

The options.

logger ILogger<PluginSystem>

The logger.

PluginSystem(ILogger<PluginSystem>)

Initializes a new instance of the PluginSystem class.

public PluginSystem(ILogger<PluginSystem> logger)

Parameters

logger ILogger<PluginSystem>

The logger.

Exceptions

ArgumentNullException

logger

PluginSystem(ILogger<PluginSystem>, IServiceProvider)

Initializes a new instance of the PluginSystem class.

public PluginSystem(ILogger<PluginSystem> logger, IServiceProvider serviceProvider)

Parameters

logger ILogger<PluginSystem>

The logger.

serviceProvider IServiceProvider

The service provider.

Exceptions

ArgumentNullException

logger

Properties

IsInitialized

Gets whether the plugin system is initialized.

public bool IsInitialized { get; }

Property Value

bool

Methods

DiscoverPluginTypes(Assembly)

Discovers plugin types in an assembly. Note: This method is not AOT-compatible and requires dynamic code compilation.

[RequiresUnreferencedCode("Plugin type discovery requires runtime type enumeration and is not AOT-compatible")]
public static IEnumerable<Type> DiscoverPluginTypes(Assembly assembly)

Parameters

assembly Assembly

Returns

IEnumerable<Type>

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

GetLoadedPlugins()

Gets all loaded plugins.

public IEnumerable<IBackendPlugin> GetLoadedPlugins()

Returns

IEnumerable<IBackendPlugin>

GetPlugin(string)

Gets a loaded plugin by ID.

public IBackendPlugin? GetPlugin(string pluginId)

Parameters

pluginId string

Returns

IBackendPlugin

InitializeAsync(CancellationToken)

Initializes the plugin system.

public Task InitializeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task

LoadPluginAsync(IBackendPlugin, CancellationToken)

Loads a plugin instance directly.

public Task<IBackendPlugin?> LoadPluginAsync(IBackendPlugin plugin, CancellationToken cancellationToken = default)

Parameters

plugin IBackendPlugin
cancellationToken CancellationToken

Returns

Task<IBackendPlugin>

LoadPluginAsync(string, string, CancellationToken)

Loads a plugin from assembly path. Note: This method is not AOT-compatible and will only work when dynamic code compilation is available. For AOT scenarios, use direct plugin registration or pre-compiled plugin factories.

[RequiresUnreferencedCode("Plugin loading from assembly path requires runtime type loading and is not AOT-compatible")]
[RequiresDynamicCode("Plugin loading requires dynamic assembly loading and is not AOT-compatible")]
public ValueTask<IBackendPlugin?> LoadPluginAsync(string assemblyPath, string pluginTypeName, CancellationToken cancellationToken = default)

Parameters

assemblyPath string
pluginTypeName string
cancellationToken CancellationToken

Returns

ValueTask<IBackendPlugin>

LoadPluginAsync(string, CancellationToken)

Loads a plugin from assembly path.

public Task<IBackendPlugin?> LoadPluginAsync(string assemblyPath, CancellationToken cancellationToken = default)

Parameters

assemblyPath string
cancellationToken CancellationToken

Returns

Task<IBackendPlugin>

UnloadPluginAsync(string, CancellationToken)

Unloads a plugin.

public ValueTask<bool> UnloadPluginAsync(string pluginId, CancellationToken cancellationToken = default)

Parameters

pluginId string
cancellationToken CancellationToken

Returns

ValueTask<bool>