Table of Contents

Class FoundryMiddlewareExtensions

Namespace
WorkflowForge.Extensions
Assembly
WorkflowForge.dll

Extension methods for IWorkflowFoundry providing middleware configuration and setup. This file focuses on middleware pipeline configuration (UseLogging, UseTiming, UseErrorHandling). For property management and operation chaining, see FoundryPropertyExtensions.

public static class FoundryMiddlewareExtensions
Inheritance
FoundryMiddlewareExtensions
Inherited Members

Methods

UseDefaultMiddleware(IWorkflowFoundry, ErrorHandlingMiddlewareOptions?, TimingMiddlewareOptions?, LoggingMiddlewareOptions?, ISystemTimeProvider?)

Configures the foundry with default middleware based on individual middleware options. This is the recommended way to configure middleware for production use. Middleware will be added in the correct order: ErrorHandling → Timing → Logging. Only enabled middleware will be registered (checked at startup, not at runtime).

public static IWorkflowFoundry UseDefaultMiddleware(this IWorkflowFoundry foundry, ErrorHandlingMiddlewareOptions? errorHandlingOptions = null, TimingMiddlewareOptions? timingOptions = null, LoggingMiddlewareOptions? loggingOptions = null, ISystemTimeProvider? timeProvider = null)

Parameters

foundry IWorkflowFoundry

The workflow foundry.

errorHandlingOptions ErrorHandlingMiddlewareOptions

Error handling middleware options (if null, uses defaults).

timingOptions TimingMiddlewareOptions

Timing middleware options (if null, uses defaults).

loggingOptions LoggingMiddlewareOptions

Logging middleware options (if null, uses defaults).

timeProvider ISystemTimeProvider

Optional time provider for timing/error handling middleware.

Returns

IWorkflowFoundry

The foundry for method chaining.

Exceptions

ArgumentException

Thrown when options validation fails.

UseErrorHandling(IWorkflowFoundry, bool, object?, ISystemTimeProvider?)

Adds error handling middleware with optional exception swallowing.

public static IWorkflowFoundry UseErrorHandling(this IWorkflowFoundry foundry, bool rethrowExceptions = true, object? defaultReturnValue = null, ISystemTimeProvider? timeProvider = null)

Parameters

foundry IWorkflowFoundry
rethrowExceptions bool
defaultReturnValue object
timeProvider ISystemTimeProvider

Returns

IWorkflowFoundry

UseLogging(IWorkflowFoundry)

Adds core logging middleware using the foundry's current logger.

public static IWorkflowFoundry UseLogging(this IWorkflowFoundry foundry)

Parameters

foundry IWorkflowFoundry

Returns

IWorkflowFoundry

UseLogging(IWorkflowFoundry, IWorkflowForgeLogger)

Adds core logging middleware using the provided logger.

public static IWorkflowFoundry UseLogging(this IWorkflowFoundry foundry, IWorkflowForgeLogger logger)

Parameters

foundry IWorkflowFoundry
logger IWorkflowForgeLogger

Returns

IWorkflowFoundry

UseTiming(IWorkflowFoundry, ISystemTimeProvider?)

Adds timing middleware for operation performance tracking.

public static IWorkflowFoundry UseTiming(this IWorkflowFoundry foundry, ISystemTimeProvider? timeProvider = null)

Parameters

foundry IWorkflowFoundry
timeProvider ISystemTimeProvider

Returns

IWorkflowFoundry