ScriptRunner.Plugins
1.6.40
See the version list below for details.
dotnet add package ScriptRunner.Plugins --version 1.6.40
NuGet\Install-Package ScriptRunner.Plugins -Version 1.6.40
<PackageReference Include="ScriptRunner.Plugins" Version="1.6.40" />
paket add ScriptRunner.Plugins --version 1.6.40
#r "nuget: ScriptRunner.Plugins, 1.6.40"
// Install ScriptRunner.Plugins as a Cake Addin #addin nuget:?package=ScriptRunner.Plugins&version=1.6.40 // Install ScriptRunner.Plugins as a Cake Tool #tool nuget:?package=ScriptRunner.Plugins&version=1.6.40
ScriptRunner.Plugins
ScriptRunner.Plugins
provides interfaces, attributes, utilities, and constants for building plugins compatible with
the ScriptRunner
framework. It ensures seamless plugin development with dynamic loading, validation, and integration.
Features
- Plugin Metadata: Annotate plugins with
[PluginMetadata]
for easy discovery and validation. - Version & Framework Constants: Ensure compatibility with
PluginSystemConstants
. - Dynamic Plugin Management: Discover, validate, and load plugins using
IPluginLoader
andDependencyLoader
. - Database Utilities: Use
IDatabase
for executing SQL queries andSqlGenerator
for dynamic SQL generation. - Local Storage: Store plugin data with
ILocalStorage
for runtime use and persistence. - Simplified Development: Use base classes like
BasePlugin
andBaseServicePlugin
to reduce boilerplate code. - Plugin Template: Quickly scaffold a new plugin project using the provided template.
Installation
Install via NuGet:
dotnet add package ScriptRunner.Plugins
Getting Started
Scaffold a New Plugin Project
The ScriptRunner.Plugins
package includes a template to help you quickly set up a plugin project. Use the dotnet new
command:
dotnet new srplugin -n MyNewPlugin
This creates a project with:
- Example plugin class (
Plugin.cs
) using[PluginMetadata]
. - Pre-configured
PluginSystemConstants
for versioning. - Example service registration with
IServicePlugin
.
Quick Start
Create a Plugin
Define your plugin class and use
[PluginMetadata]
for metadata:using ScriptRunner.Plugins.Attributes; using ScriptRunner.Plugins.Utilities; [PluginMetadata( name: "SamplePlugin", description: "A simple plugin example.", author: "Your Name", version: "1.0.0", pluginSystemVersion: PluginSystemConstants.CurrentPluginSystemVersion, frameworkVersion: PluginSystemConstants.CurrentFrameworkVersion)] public class SamplePlugin : IPlugin { public void Initialize(IDictionary<string, object> configuration) => Console.WriteLine("Initialized."); public void Execute() => Console.WriteLine("Executed."); }
Register services if needed:
public class SampleServicePlugin : IServicePlugin { public void RegisterServices(IServiceCollection services) { services.AddSingleton<IMyService, MyService>(); } }
Utilities
Versioning with Constants
Use PluginSystemConstants
to ensure host and plugin version compatibility:
public static class PluginSystemConstants
{
public const string CurrentPluginSystemVersion = "1.2.0";
public const string CurrentFrameworkVersion = ".NET 8.0";
}
Dynamic Dependency Management
Load dependencies dynamically with DependencyLoader
:
DependencyLoader.SetSkipLibraries(new[] { "sqlite3.dll" });
DependencyLoader.LoadDependencies("path/to/dependencies", new ConcurrentDictionary<string, bool>(), logger);
Database Utilities
- Use
IDatabase
for database interaction. - Use
SqlGenerator
for generating queries dynamically:
var generator = new SqlGenerator();
generator.SetType(typeof(MyEntity));
generator.SetTableName("MyTable");
var query = generator.GenerateSelectQuery();
Local Storage
Use ILocalStorage
for temporary data storage and persistence:
var storage = new LocalStorage();
storage.SetData("key", "value");
storage.SaveToFile("storage.json");
storage.LoadFromFile("storage.json");
Simplified Development
Use base classes like BasePlugin
or BaseAsyncServicePlugin
to minimize repetitive code.
Example with BasePlugin
:
public class MyPlugin : BasePlugin
{
public override void Initialize(IDictionary<string, object> configuration) => Console.WriteLine("Initialized.");
public override void Execute() => Console.WriteLine("Executed.");
}
Contributing
Contributions are welcome! Submit issues or PRs on GitHub.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.CodeAnalysis.Common (>= 4.12.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.12.0)
- Microsoft.Data.Sqlite (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
- System.Reflection.MetadataLoadContext (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.