RkSoftware.RKPlugin 0.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package RkSoftware.RKPlugin --version 0.4.0
                    
NuGet\Install-Package RkSoftware.RKPlugin -Version 0.4.0
                    
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="RkSoftware.RKPlugin" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RkSoftware.RKPlugin" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="RkSoftware.RKPlugin" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RkSoftware.RKPlugin --version 0.4.0
                    
#r "nuget: RkSoftware.RKPlugin, 0.4.0"
                    
#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.
#:package RkSoftware.RKPlugin@0.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RkSoftware.RKPlugin&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=RkSoftware.RKPlugin&version=0.4.0
                    
Install as a Cake Tool

RKPlugin

NuGet version (RkSoftware.RKPlugin) workflow

Usage

Applocation Code

Example in a web application
This is the code that calls the "ConfigureServices" method of the plugin library.

var pluginPath = Path.Combine(Assembly.GetEntryAssembly()?.Location!, "../../../../../TestPlugin/bin/Debug/net10.0");
var plugins = PluginLoadContext.LoadExtensions(pluginPath);
foreach (var plugin in plugins)
    foreach (var assembly in plugin.Assemblies)
        foreach (var type in assembly.GetTypes())
        {
            var method = type.GetMethod("ConfigureServices");
            if (method != null)
            {
                var result = PluginLoadContext.Invoke(services, method, null, null);
                Debug.Write(result);
            }
        }
Plugin Library Code

Create a class library project
Use the methods of the "PluginServiceCollection" class in the "ConfigureServices" method.

The plugin does not need to reference assemblies such as "Microsoft.Extensions.Http" or "Microsoft.Extensions.DependencyInjection.Abstractions".

public class Class1
{
    public static string ConfigureServices(object services)
    {
        var r01 = PluginServiceCollection.AddHttpClient<ITest, Test>(services, F01)?.ToString();
        var r02 = PluginServiceCollection.AddScoped(services, F02)?.ToString();
        return string.Join(", ", r02, r02);
    }
    static Test F01(HttpClient httpClient) => new Test();
    static Test F02(IServiceProvider serviceProvider) => new Test();
}

Where to put the class library DLL

The DLL file will be loaded as a plugin by placing it in the path specified in the argument of the PluginLoadContext.LoadExtensions method.

var pluginPath = Path.Combine(Assembly.GetEntryAssembly()?.Location!, "../../../../../TestPlugin/bin/Debug/net10.0");
var plugins = PluginLoadContext.LoadExtensions(pluginPath);

What is implemented

Extension Methods on ServiceCollection

  • AddTransient
  • AddScoped
  • AddSingleton
  • AddHttpClient
  • ConfigureHttpClientDefaults

"Microsoft.Extensions.DependencyInjection.HttpClientFactoryServiceCollectionExtensions,Microsoft.Extensions.Http"
"Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions,Microsoft.Extensions.DependencyInjection.Abstractions"

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.  net9.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

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
0.5.0 294 6/10/2025
0.4.0 122 6/7/2025
0.3.0 104 5/25/2025
0.2.0 115 4/6/2025
0.1.1 146 3/30/2025
0.1.0 121 3/29/2025