ScriptBee's Plugin API
DxWorks.ScriptBee.Plugin.Api
ScriptBee's plugin API provides a way to extend the functionality of the system. Plugins can be used to add custom loaders, linkers, script generators, script runners, and helper functions.
Currently, ScriptBee supports the following types of plugins:
- Loader Plugins
- Linker Plugins
- Helper Functions Plugins
- Script Generator Plugins
- Script Runner Plugins
- Bundle Plugins
Every plugin must have a manifest.yaml file in its root directory. More information about the manifest can be found in the manifest section.
Services
Besides the plugin interfaces, ScriptBee offers a set of services that can be used by plugins via dependency injection.
IHelperFunctionsContainer
The IHelperFunctionsContainer service is used to register helper functions. Helper functions are a way to extend the functionality of ScriptBee. They can be used to add custom functions that can be used in the scripts directly.
IHelperFunctionsContainer wraps the helper functions and provides a way to access them.
public interface IHelperFunctionsContainer
{
public Dictionary<string, Delegate> GetFunctionsDictionary();
public IEnumerable<IHelperFunctions> GetFunctions();
}ScriptRunner uses the IHelperFunctionsContainer service to get the helper functions and add them to the script engine.
IHelperFunctionsResultService
The IHelperFunctionsResultService service is used to store the results of the helper functions and have a uniform way to deal with script outputs.
public interface IHelperFunctionsResultService
{
Task UploadResultAsync(string fileName, string type, string content, CancellationToken cancellationToken = default);
Task UploadResultAsync(string fileName, string type, Stream content, CancellationToken cancellationToken = default);
void UploadResult(string fileName, string type, string content);
void UploadResult(string fileName, string type, Stream content);
}ScriptBee's default helper functions use the IHelperFunctionsResultService service to upload the results of the helper functions.
Run Result Types
ScriptBee has a set of predefined result types that can be used by the helper functions to upload the results.
public static class RunResultDefaultTypes
{
public const string ConsoleType = "Console";
public const string FileType = "File";
public const string RunError = "RunError";
}