Jiro.Commands
1.0.6
See the version list below for details.
dotnet add package Jiro.Commands --version 1.0.6
NuGet\Install-Package Jiro.Commands -Version 1.0.6
<PackageReference Include="Jiro.Commands" Version="1.0.6" />
<PackageVersion Include="Jiro.Commands" Version="1.0.6" />
<PackageReference Include="Jiro.Commands" />
paket add Jiro.Commands --version 1.0.6
#r "nuget: Jiro.Commands, 1.0.6"
#:package Jiro.Commands@1.0.6
#addin nuget:?package=Jiro.Commands&version=1.0.6
#tool nuget:?package=Jiro.Commands&version=1.0.6
Jiro.Commands
Command base and plugin manager for Jiro. Jiro.Commands is a command base and plugin manager designed to facilitate the creation of plugins and custom commands for Jiro. It provides a flexible and efficient way to extend the functionality of your application through the use of plugins.
The plugin management feature of Jiro.Commands provides a standardized way to load and unload plugins, improving the maintainability and scalability of your application. It allows you to quickly add new features to your application without needing to rebuild it from scratch.
In summary, Jiro.Commands is a powerful and versatile library that allows you to extend and optimize the functionality of your Jiro application, quickly and easily.
Plugin creation
To create a plugin, you have to create your own class that will inherit IPlugin
interface
public class PluginMain : IPlugin
{
public string PluginName { get; } = "PluginMain";
// optional
public void RegisterAppConfigs(ConfigurationManager builder)
{
builder.AddJsonFile("example.config.json", optional: true, reloadOnChange: true);
}
// optional
public void RegisterAppExtensions(IApplicationBuilder app)
{
app.UsePluginMiddleware();
}
public void RegisterServices(IServiceCollection services)
{
services.AddScoped<IPluginService, PluginService>();
}
}
public string PluginName { get; } = "PluginMain";
- This property returns the name of the plugin.public void RegisterAppConfigs(ConfigurationManager builder)
- This method is optional and allows the plugin to register configuration files. In this case, an example example.config.json file is registered as a JSON file that can be reloaded on changes.public void RegisterAppExtensions(IApplicationBuilder app)
- This method is optional and allows the plugin to register additional middleware for the application. Here, theUsePluginMiddleware
method is registered as an extension method for anIApplicationBuilder
instance.public void RegisterServices(IServiceCollection services)
- This method is used to register services that the plugin provides or requires. In this case, an instance ofPluginService
class is registered as a service that can be injected using theAddScoped
extension method forIServiceCollection
.
Custom Controllers
To create a custom controller, you have to create your own class that will inherit BaseController
class
public class PluginController : BaseController
{
public PluginController() { }
[HttpGet("PluginTest")]
public IActionResult PluginTest()
{
return Ok("Plugin Controller Executed");
}
}
Custom Commands
Commands have scoped lifetime by default.
[CommandModule("PluginCommand")]
public class PluginCommand : ICommandBase
{
private readonly IPluginService _pluginService;
public PluginCommand(IPluginService pluginService)
{
_pluginService = pluginService;
}
[Command("PluginTest", commandSyntax: "PluginTest", commandDescription: "Tests plugin command")]
public async Task<ICommandResult> PluginTest()
{
_pluginService.ServiceTest();
await Task.Delay(1000);
return TextResult.Create("Plugin Command Executed");
}
}
[CommandModule("PluginCommand")]
- This attribute is used to define a command module, which acts as a container for commands. In this case, the module name is "PluginCommand".public class PluginCommand : ICommandBase
- This class implements the ICommandBase interface and is a command.public PluginCommand(IPluginService pluginService)
- The command's constructor injects an instance of IPluginService as a dependency.[Command("PluginTest", commandSyntax: "PluginTest", commandDescription: "Tests plugin command")]
- This attribute is used to define a command within the PluginCommand module. Here, the command name is "PluginTest" and it has a description "Tests plugin command". It also provides the command syntax as"PluginTest"
.return TextResult.Create("Plugin Command Executed");
- Finally, returns the result of the command execution. In this case, it creates a new instance of a TextResult object that contains the string message "Plugin Command Executed".
The requirements for commands:
- Class must contain
[CommandModuleAttribute]
- Class must inherit
ICommandBase
- Command Method must contain
[CommandAttribute]
with at least a command name - Command Method must return
Task<ICommandResult>
- Use
TextResult.Create
,ImageResult.Create
,GraphResult.Create
for creatingICommandResult
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- Microsoft.AspNet.Mvc (>= 5.2.9)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.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.
Initial