Class PluginExtensions
Extension methods for plugin registration and hook collection.
Inherited Members
Namespace: LaunchDarkly.Sdk.Integrations.Plugins
Assembly: LaunchDarkly.CommonSdk.dll
Syntax
public static class PluginExtensions
Methods
GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
Retrieves all hooks from the specified plugins.
Declaration
public static List<THook> GetPluginHooks<TClient, THook>(this TClient client, IEnumerable<PluginBase<TClient, THook>> plugins, EnvironmentMetadata environmentMetadata, Logger logger)
Parameters
| Type | Name | Description |
|---|---|---|
| TClient | client | The client instance to register plugins with |
| IEnumerable<PluginBase<TClient, THook>> | plugins | The collection of plugins |
| EnvironmentMetadata | environmentMetadata | Metadata about the environment |
| Logger | logger | Logger for error reporting |
Returns
| Type | Description |
|---|---|
| List<THook> | A list of hooks from all plugins |
Type Parameters
| Name | Description |
|---|---|
| TClient | The client type |
| THook | The hook type |
Remarks
This method iterates through each plugin in the collection and calls its GetHooks method
to retrieve any hooks the plugin provides. It logs any exceptions that occur during
the hook retrieval process and continues processing remaining plugins.
RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
Registers all plugins with the client and environment metadata.
Declaration
public static void RegisterPlugins<TClient, THook>(this TClient client, IEnumerable<PluginBase<TClient, THook>> plugins, EnvironmentMetadata environmentMetadata, Logger logger)
Parameters
| Type | Name | Description |
|---|---|---|
| TClient | client | The client instance to register plugins with |
| IEnumerable<PluginBase<TClient, THook>> | plugins | The collection of plugins to register |
| EnvironmentMetadata | environmentMetadata | Metadata about the environment |
| Logger | logger | Logger for error reporting |
Type Parameters
| Name | Description |
|---|---|
| TClient | The client type (e.g., ILdClient) |
| THook | The hook type (e.g., Hook) |
Remarks
This method iterates through each plugin in the collection and calls its Register method
to initialize it with the client and environment metadata. It logs any exceptions that occur during
the registration process, allowing the client to continue functioning even if some plugins fail to register.