https://github.com/flowsynx/plugin-core
Plugin interface for create new plugin for FlowSynx engine
https://github.com/flowsynx/plugin-core
flowsynx plugin-core plugin-designer
Last synced: 3 months ago
JSON representation
Plugin interface for create new plugin for FlowSynx engine
- Host: GitHub
- URL: https://github.com/flowsynx/plugin-core
- Owner: flowsynx
- License: mit
- Created: 2025-04-04T15:04:23.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-12-06T11:19:08.000Z (6 months ago)
- Last Synced: 2026-02-16T08:46:04.435Z (4 months ago)
- Topics: flowsynx, plugin-core, plugin-designer
- Language: C#
- Homepage:
- Size: 95.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
๏ปฟ# FlowSynx PluginCore
**FlowSynx PluginCore** is a lightweight, extensible plugin execution framework designed for modular application architecture.
It supports structured error handling, versioning, logging, and flexible plugin execution with parameter and specification support.
---
## โจ Features
- ๐ **Plugin Interface**: Define reusable plugins with metadata, specifications, and execution logic.
- โ๏ธ **Execution Parameters**: Pass dynamic parameters and retrieve results using a standardized dictionary.
- ๐ **Specifications Model**: Configure plugins with reusable specifications.
- ๐ชต **Plugin Logging**: Built-in logger interface with multiple severity levels.
- ๐งช **Versioning System**: Compare and manage plugin versions (`Major.Minor.Patch`).
- โ **Custom Error Handling**: Structured exceptions and codes via `FlowSynxException` and `ErrorMessage`.
- ๐ท๏ธ **Required Attributes**: Decorate required specification fields with `RequiredMemberAttribute`.
---
## ๐งฉ Core Concepts
### โ
IPlugin Interface
The heart of the framework, the `IPlugin` interface, enforces a contract for plugin implementation:
```csharp
public interface IPlugin
{
PluginMetadata Metadata { get; }
PluginSpecifications? Specifications { get; set; }
Type SpecificationsType { get; }
Task Initialize(IPluginLogger logger);
Task ExecuteAsync(PluginParameters parameters, CancellationToken cancellationToken);
}
```
- Metadata: Descriptive data like name, description, author, etc.
- Specifications: Custom configuration for plugin behavior.
- SpecificationsType: Strongly typed representation of specifications (with validation).
- Initialize: Called before execution, typically for setup or validation.
- ExecuteAsync: The main execution method, receiving input parameters and returning results.
## โ๏ธ Plugin Metadata & Specifications
A case-insensitive dictionary allowing plugins to define required and optional configuration options. Supports deep cloning and dynamic usage:
```csharp
public class PluginSpecifications : Dictionary, ICloneable
```
Supports `[RequiredMember]` attribute for validation:
```csharp
[RequiredMember]
public string RequiredSetting { get; set; }
```
### Create simple specifications
```csharp
public class MyPluginSpecs : PluginSpecifications
{
[RequiredMember]
public string RequiredSetting { get; set; } = "default";
}
```
## ๐ฆ Parameters and Cloning
`PluginParameters` provides a flexible, case-insensitive dictionary to pass runtime data to plugins:
```csharp
public class PluginParameters : Dictionary, ICloneable
```
Use `.Clone()` for safe state reuse.
## ๐ Logging
Plugins receive a logging abstraction to emit structured logs:
```csharp
public interface IPluginLogger
{
void Log(PluginLoggerLevel level, string message);
}
```
### Log Levels
Use the logger with severity levels or extension methods:
```csharp
public enum PluginLoggerLevel
{
Debug,
Information,
Warning,
Error
}
```
#### Logger Extensions
```csharp
logger.LogInfo("Started processing...");
logger.LogError("An error occurred.");
```
## ๐งญ Categories Support
To organize plugins by type or domain, use the `PluginNamespace` enum:
```csharp
public enum PluginCategory
{
AI,
Api,
Authentication,
BusinessIntelligence,
Blockchain,
Cloud,
Communication,
Data,
Database,
DevOps,
Finance,
ML,
Monitoring,
Logging,
Networking,
ProjectWorkflow,
ResourcePlanning,
Security,
Storage,
Testing,
Web
}
```
## ๐งช Example Plugin
```csharp
public class SampleGreetingPlugin : IPlugin
{
public PluginMetadata Metadata => new()
{
Id = Guid.Parse("fc58122d-6444-4c5b-ab3d-8cff62283a08"),
Name = "MyPlugin",
Description = "This is a test plugin.",
Version = new PluginVersion(1, 0, 0),
Namespace = PluginNamespace.Api,
CompanyName = "FlowSynx",
Authors = new List { "FlowSynx" },
Copyright = "ยฉ FlowSynx. All rights reserved.",
Tags = new List() { "MyCompany", "TestPlugin" }
};
public PluginSpecifications? Specifications { get; set; }
public Type SpecificationsType => typeof(GreetingSpecs);
public Task Initialize(IPluginLogger logger)
{
logger.LogInfo("Initializing GreetingPlugin...");
return Task.CompletedTask;
}
public Task ExecuteAsync(PluginParameters parameters, CancellationToken cancellationToken)
{
string name = parameters.TryGetValue("name", out var value) ? value?.ToString() ?? "World" : "World";
return Task.FromResult($"Hello, {name}!");
}
}
```