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
optionsPluginOptionsThe options.
loggerILogger<PluginSystem>The logger.
PluginSystem(ILogger<PluginSystem>)
Initializes a new instance of the PluginSystem class.
public PluginSystem(ILogger<PluginSystem> logger)
Parameters
loggerILogger<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
loggerILogger<PluginSystem>The logger.
serviceProviderIServiceProviderThe service provider.
Exceptions
- ArgumentNullException
logger
Properties
IsInitialized
Gets whether the plugin system is initialized.
public bool IsInitialized { get; }
Property Value
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
assemblyAssembly
Returns
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
disposingbooltrueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetLoadedPlugins()
Gets all loaded plugins.
public IEnumerable<IBackendPlugin> GetLoadedPlugins()
Returns
GetPlugin(string)
Gets a loaded plugin by ID.
public IBackendPlugin? GetPlugin(string pluginId)
Parameters
pluginIdstring
Returns
InitializeAsync(CancellationToken)
Initializes the plugin system.
public Task InitializeAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
LoadPluginAsync(IBackendPlugin, CancellationToken)
Loads a plugin instance directly.
public Task<IBackendPlugin?> LoadPluginAsync(IBackendPlugin plugin, CancellationToken cancellationToken = default)
Parameters
pluginIBackendPlugincancellationTokenCancellationToken
Returns
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
assemblyPathstringpluginTypeNamestringcancellationTokenCancellationToken
Returns
LoadPluginAsync(string, CancellationToken)
Loads a plugin from assembly path.
public Task<IBackendPlugin?> LoadPluginAsync(string assemblyPath, CancellationToken cancellationToken = default)
Parameters
assemblyPathstringcancellationTokenCancellationToken
Returns
UnloadPluginAsync(string, CancellationToken)
Unloads a plugin.
public ValueTask<bool> UnloadPluginAsync(string pluginId, CancellationToken cancellationToken = default)
Parameters
pluginIdstringcancellationTokenCancellationToken