ScriptRunner.Plugins 1.6.44

dotnet add package ScriptRunner.Plugins --version 1.6.44                
NuGet\Install-Package ScriptRunner.Plugins -Version 1.6.44                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ScriptRunner.Plugins" Version="1.6.44" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ScriptRunner.Plugins --version 1.6.44                
#r "nuget: ScriptRunner.Plugins, 1.6.44"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ScriptRunner.Plugins as a Cake Addin
#addin nuget:?package=ScriptRunner.Plugins&version=1.6.44

// Install ScriptRunner.Plugins as a Cake Tool
#tool nuget:?package=ScriptRunner.Plugins&version=1.6.44                

ScriptRunner.Plugins

NuGet NuGet Downloads License

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 and DependencyLoader.
  • Database Utilities: Use IDatabase for executing SQL queries and SqlGenerator for dynamic SQL generation.
  • Local Storage: Store plugin data with ILocalStorage for runtime use and persistence.
  • Simplified Development: Use base classes like BasePlugin and BaseServicePlugin 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

  1. 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.");
    }
    
  2. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.44 72 12/22/2024
1.6.42 82 12/21/2024
1.6.40 69 12/21/2024
1.6.38 82 12/21/2024