Table of Contents

Class ActivityContextExtensions

Namespace
Excalibur.Data
Assembly
Excalibur.Data.dll

Provides extension methods for accessing contextual information from an IActivityContext instance.

public static class ActivityContextExtensions
Inheritance
ActivityContextExtensions
Inherited Members

Methods

ApplicationName(IActivityContext)

Retrieves the application name from the activity context.

public static string? ApplicationName(this IActivityContext context)

Parameters

context IActivityContext

The activity context.

Returns

string

The application name carried by the context, or an empty string when the context does not carry one. The context is the only source consulted: an ambient process-wide value is not substituted, because a caller cannot tell a value the context supplied from one it did not.

Exceptions

ArgumentNullException

Thrown if context is null .

ClientAddress(IActivityContext)

Retrieves the client address from the activity context, if available.

public static string? ClientAddress(this IActivityContext context)

Parameters

context IActivityContext

The activity context.

Returns

string

The client address, or null if not available.

Exceptions

ArgumentNullException

Thrown if context is null .

Configuration(IActivityContext)

Retrieves the configuration from the activity context.

public static IConfiguration Configuration(this IActivityContext context)

Parameters

context IActivityContext

The activity context.

Returns

IConfiguration

The configuration instance.

Exceptions

ArgumentNullException

Thrown if context is null .

CorrelationId(IActivityContext)

Retrieves the correlation ID from the activity context.

public static Guid? CorrelationId(this IActivityContext context)

Parameters

context IActivityContext

The activity context.

Returns

Guid?

The correlation ID, or Empty if not set.

Exceptions

ArgumentNullException

Thrown if context is null .

DomainDb(IActivityContext)

Retrieves the IDomainDb service from the activity context.

public static IDomainDb DomainDb(this IActivityContext context)

Parameters

context IActivityContext

The activity context.

Returns

IDomainDb

The scoped IDomainDb instance.

Exceptions

ArgumentNullException

Thrown if context is null .

ETag(IActivityContext)

Retrieves the incoming ETag from the activity context.

public static string? ETag(this IActivityContext context)

Parameters

context IActivityContext

The activity context.

Returns

string

The incoming ETag, or null if not set.

Exceptions

ArgumentNullException

Thrown if context is null .

ETag(IActivityContext, string?)

Sets the outgoing ETag in the activity context.

public static void ETag(this IActivityContext context, string? newETag)

Parameters

context IActivityContext

The activity context.

newETag string

The new ETag to set.

Exceptions

ArgumentNullException

Thrown if context is null .

Get<T>(IActivityContext, string)

Retrieves a value of type T from the activity context by its key.

public static T? Get<T>(this IActivityContext context, string key)

Parameters

context IActivityContext

The activity context.

key string

The key associated with the value.

Returns

T

The value associated with the key, or null if not found.

Type Parameters

T

The type of the value to retrieve.

Exceptions

ArgumentNullException

Thrown if context is null .

LatestETag(IActivityContext)

Retrieves the most recent ETag (outgoing if set, otherwise incoming) from the activity context.

public static string? LatestETag(this IActivityContext context)

Parameters

context IActivityContext

The activity context.

Returns

string

The latest ETag, or null if not set.

Exceptions

ArgumentNullException

Thrown if context is null .

ServiceProvider(IActivityContext)

Retrieves the service provider from the activity context.

public static IServiceProvider ServiceProvider(this IActivityContext context)

Parameters

context IActivityContext

The activity context.

Returns

IServiceProvider

The service provider instance.

Exceptions

ArgumentNullException

Thrown if context is null .

TenantId(IActivityContext)

Retrieves the tenant ID from the activity context.

public static string? TenantId(this IActivityContext context)

Parameters

context IActivityContext

The activity context.

Returns

string

The tenant ID.

Exceptions

ArgumentNullException

Thrown if context is null .