Class BowireServiceCollectionExtensions

Namespace
Kuestenlogik.Bowire
Assembly
Kuestenlogik.Bowire.dll

DI-container extensions that wire Bowire and its installed protocol plugins into an ASP.NET application.

public static class BowireServiceCollectionExtensions
Inheritance
BowireServiceCollectionExtensions
Inherited Members

Remarks

Paired with MapBowire(IEndpointRouteBuilder, string, Action<BowireOptions>?): call AddBowire() in Program.cs before builder.Build(), then MapBowire() on the resulting app.

Methods

AddBowire(IServiceCollection)

Registers Bowire and auto-configures the DI prerequisites for every installed protocol plugin.

public static IServiceCollection AddBowire(this IServiceCollection services)

Parameters

services IServiceCollection

The application's service collection.

Returns

IServiceCollection

The same services instance, so calls can be chained (for example with .AddBowire().AddAuthentication(…)).

Examples

Without AddBowire, protocols must be configured by hand:

builder.Services.AddGrpc();
builder.Services.AddGrpcReflection();
// ... and every other protocol's own setup ...
var app = builder.Build();
app.MapGrpcReflectionService();
app.MapBowire();

With AddBowire, a single line covers every referenced plugin:

builder.Services.AddBowire();
var app = builder.Build();
app.MapBowire();

Remarks

Scans every loaded assembly whose name starts with Kuestenlogik.Bowire for types that implement IBowireProtocolServices and invokes ConfigureServices(IServiceCollection) on each. Only protocols whose NuGet package is actually referenced by the host project are activated — no gRPC reference means no gRPC Server Reflection is registered, no SignalR reference means no hub enumeration, and so on.

A preliminary pass force-loads every Kuestenlogik.Bowire*.dll from the application's output directory so that plugins shipped as runtime dependencies (but not touched by the CLR yet) are discovered too. Assemblies that fail to enumerate types are silently skipped to keep startup resilient in misconfigured deployments.

See Also

AddBowirePlugins(IServiceCollection, IConfiguration)

Overload that reads the plugin directory from a bound IConfiguration. Looks at Bowire:PluginDir; returns unchanged when the key is unset so callers can wire this into their startup pipeline unconditionally.

public static IServiceCollection AddBowirePlugins(this IServiceCollection services, IConfiguration configuration)

Parameters

services IServiceCollection
configuration IConfiguration

Returns

IServiceCollection

Remarks

This is the preferred wiring for embedded hosts that already build an IConfiguration from appsettings.json or similar:

builder.Services
       .AddBowirePlugins(builder.Configuration)
       .AddBowire();

Plugins themselves read their own config section via the standard .NET options pattern:

public void ConfigureServices(IServiceCollection services)
{
    services.AddOptions<MyPluginOptions>()
            .BindConfiguration("Bowire:Plugins:MyPlugin");
}

AddBowirePlugins(IServiceCollection, string)

Load every .dll under pluginDir into the default AssemblyLoadContext so the subsequent AddBowire(IServiceCollection) reflection pass picks the plugins up. Intended for embedded hosts that want to extend the workbench with out-of-tree protocol plugins without depending on the bowire CLI tool.

public static IServiceCollection AddBowirePlugins(this IServiceCollection services, string pluginDir)

Parameters

services IServiceCollection

The application's service collection (returned unchanged, for chaining).

pluginDir string

Directory to scan. Per-package subdirectories (pluginDir/<package>/*.dll) are the primary layout — matches what bowire plugin install produces — but loose DLLs at the top level are picked up too.

Returns

IServiceCollection

Remarks

Non-existent paths are treated as empty (no throw) so callers can blindly pass a configured directory even when no plugins have been installed yet. DLLs that fail to load are silently skipped — the equivalent behaviour to the bowire CLI's plugin loader. Call this before AddBowire(IServiceCollection).