Winterborn.Library.PluginArchitecture 3.1.0

dotnet add package Winterborn.Library.PluginArchitecture --version 3.1.0
                    
NuGet\Install-Package Winterborn.Library.PluginArchitecture -Version 3.1.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="Winterborn.Library.PluginArchitecture" Version="3.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Winterborn.Library.PluginArchitecture" Version="3.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Winterborn.Library.PluginArchitecture" />
                    
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 Winterborn.Library.PluginArchitecture --version 3.1.0
                    
#r "nuget: Winterborn.Library.PluginArchitecture, 3.1.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 Winterborn.Library.PluginArchitecture@3.1.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=Winterborn.Library.PluginArchitecture&version=3.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Winterborn.Library.PluginArchitecture&version=3.1.0
                    
Install as a Cake Tool

Plugin Architecture

This library provides a simple way of implementing a plug-in architecture. To use this plugin, there are a small number of simple steps.

TL;DR

You can use this library to dynamically load types that implement any interface you define. Those types can be scattered across multiple assemblies. This makes it easy to implement a plug-in architecture with many options about how to distribute and organize the code.

var plugins = Plugins.Load();
var instances = plugins.GetInstances<interface>();
foreach(var instance in instances)
{
    instance.DoSomething();
}

Step 0 - Download this library

I'm going to go ahead and assume you know how to do that or have already done so.

Step 1 - Identify a Use Case

Where you want to implement a Plug-in architecture, define an interface.

Provide one or more concrete implementations of the interface.

Step 2 - Load the Plugin Engine

Load the plugin engine

var plugins = Plugins.Load();

You may optionally provide a specific directory as a load parameter parameter. If you do not, the current context's environment directory will be used (most likely the directory where the current executable was invoked from).

var plugins = Plugins.Load("Absolute or Relative directory");

Alternatively, you can pass the exact assemblies from which you want to load your plugins to the load method.

var plugins = Plugins.Load(Assembly1, Assembly2, Assembly3);

The scope of all subsequent methods invoked on the plugin engine will interact with all types, in all dlls, in the provided directory and (recursively) all sub-directories.

Step 3 - Load the Plugin Engine

There are two ways of interacting with the plugin engine.

Step 3.1 - Load the Plugin Types

You may load all types that implement a given interface.

Use this method if you just need to get metadata about the type or use custom constructors.

var types = plugins.GetTypes<interface>();

Step 3.2 - Load the Plugin Implementations

You may load an instance of every type that implements a given interface.

Use this method if you want to actually interact with an instance of type plug-in types.

An important disclaimer is that this only works if the plug-in types have a parameterless constructor.

var instances = plugins.GetInstances<interface>();

Using the Factory

This library provides a super simple implementation of a basic factory pattern. The factory allows for users to specify a concrete type to use when an interface is requested. Any future code requesting an instance of the interface will have a new instance of the concrete type created and sent over.

The example below highlights the full lifecycle of this simple factory implement.

var factory = new Factory();
factory.SetImplementation<interface,class>();
var instance = factory.Make<interface>();

Notes

  • The concrete types provided must have a parameterless constructor (it's not enough to provide default values)
  • The factory type itself is not a singleton, so to make best possible use of it you should create it at start-up and then pass it around (or make your own singleton)
  • It's configuration is done with code (not app settings) to aide in refactoring and testing
Product Compatible and additional computed target framework versions.
.NET 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.

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
3.1.0 100 8/10/2026
3.0.0 97 8/10/2026
2.0.0 107 8/10/2026
1.1.0 97 8/10/2026
1.0.35 107 8/3/2026