Interface IPluginService
- Namespace
- SharpConsoleUI.Plugins
- Assembly
- SharpConsoleUI.dll
Base interface for all service plugins that can be invoked without reflection. Services expose operations that can be discovered and invoked dynamically through a convention-based Execute method.
public interface IPluginService
Remarks
This interface enables a reflection-free service plugin pattern where external DLLs don't need to share specific interfaces with the host application. Services define their own operations with rich metadata for discoverability, and the host invokes them through a generic Execute method with string-based operation names and dictionary-based parameters.
Example usage:
var service = windowSystem.GetPluginService("Diagnostics");
long memory = (long)service.Execute("GetMemoryUsage");
var report = (string)service.Execute("GetDetailedReport", new Dictionary<string, object>
{
["includeGC"] = true,
["includeThreads"] = false
});
Properties
Description
Gets a human-readable description of what this service provides.
string Description { get; }
Property Value
ServiceName
Gets the unique name of this service. This is used to retrieve the service from the plugin system.
string ServiceName { get; }
Property Value
Examples
"Diagnostics", "Logger", "Authentication"
Methods
Execute(string, Dictionary<string, object>?)
Executes a named operation with optional parameters.
object? Execute(string operationName, Dictionary<string, object>? parameters = null)
Parameters
operationNamestringThe name of the operation to execute
parametersDictionary<string, object>Optional dictionary of parameter name/value pairs
Returns
- object
The result of the operation, or null if the operation returns void
Remarks
Parameter values should match the types declared in the operation metadata. The caller is responsible for casting the return value to the expected type based on the operation metadata.
Exceptions
- InvalidOperationException
Thrown if the operation name is unknown or parameters are invalid
GetAvailableOperations()
Gets the list of operations this service supports, with full metadata about parameters, return types, and descriptions. This enables runtime discovery and self-documenting service interfaces.
IReadOnlyList<ServiceOperation> GetAvailableOperations()
Returns
- IReadOnlyList<ServiceOperation>
A read-only list of operation metadata