Table of Contents

Class IronLedgerServiceExtensions

Namespace
Tudormobile.IronLedgerLib.Services
Assembly
Tudormobile.IronLedgerLib.Services.dll

Provides extension methods for registering and configuring IronLedger client and service components with dependency injection and for mapping IronLedger service endpoints to a web application.

public static class IronLedgerServiceExtensions
Inheritance
IronLedgerServiceExtensions
Inherited Members

Remarks

These extension methods simplify the integration of IronLedger functionality into ASP.NET Core applications by handling service registration and endpoint mapping. Use these methods during application startup to ensure that IronLedger services and endpoints are properly configured.

Methods

AddIronLedgerClient(IServiceCollection, Action<IronLedgerClientOptions>)

Adds the IronLedger HTTP client to the specified IServiceCollection.

public static IServiceCollection AddIronLedgerClient(this IServiceCollection services, Action<IronLedgerClientOptions> configure)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

configure Action<IronLedgerClientOptions>

Action to configure IronLedgerClientOptions. Must set ServerUrl.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Remarks

Use this method in client-only applications (console, WPF, MAUI, Blazor) that communicate with a remote IronLedger service. For applications that host the service, use AddIronLedgerService(IServiceCollection, Action<IronLedgerOptions>?) instead.

AddIronLedgerService(IServiceCollection, Action<IronLedgerOptions>?)

Adds the IronLedger client and service to the specified IServiceCollection.

public static IServiceCollection AddIronLedgerService(this IServiceCollection services, Action<IronLedgerOptions>? configure = null)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

configure Action<IronLedgerOptions>

Optional action to configure the IronLedgerClient.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

UseIronLedgerExceptionHandler(WebApplication)

Adds the IronLedger exception handling middleware to the web application's request pipeline.

public static WebApplication UseIronLedgerExceptionHandler(this WebApplication app)

Parameters

app WebApplication

The web application instance to which the middleware is added.

Returns

WebApplication

The web application instance with the exception handler middleware added.

Remarks

Call this method before other middleware that may throw exceptions, typically as one of the first entries in the pipeline. Requires AddIronLedgerService(IServiceCollection, Action<IronLedgerOptions>?) to have been called during service registration.

UseIronLedgerService(WebApplication, string)

Maps the Iron Ledger service endpoints to the specified web application using the provided URL prefix.

public static WebApplication UseIronLedgerService(this WebApplication app, string prefix = "")

Parameters

app WebApplication

The web application instance to which the service endpoints are added.

prefix string

The URL prefix used to namespace the service endpoints. Must be a valid URL segment if it is provided.

Returns

WebApplication

The web application instance with the service endpoints mapped.

Remarks

This method maps HTTP routes for Iron Ledger endpoints. Call UseIronLedgerExceptionHandler(WebApplication) separately to add exception handling middleware to the pipeline.