Class ActivityContextExtensions
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
contextIActivityContextThe 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
contextisnull.
ClientAddress(IActivityContext)
Retrieves the client address from the activity context, if available.
public static string? ClientAddress(this IActivityContext context)
Parameters
contextIActivityContextThe activity context.
Returns
- string
The client address, or
nullif not available.
Exceptions
- ArgumentNullException
Thrown if
contextisnull.
Configuration(IActivityContext)
Retrieves the configuration from the activity context.
public static IConfiguration Configuration(this IActivityContext context)
Parameters
contextIActivityContextThe activity context.
Returns
- IConfiguration
The configuration instance.
Exceptions
- ArgumentNullException
Thrown if
contextisnull.
CorrelationId(IActivityContext)
Retrieves the correlation ID from the activity context.
public static Guid? CorrelationId(this IActivityContext context)
Parameters
contextIActivityContextThe activity context.
Returns
Exceptions
- ArgumentNullException
Thrown if
contextisnull.
DomainDb(IActivityContext)
Retrieves the IDomainDb service from the activity context.
public static IDomainDb DomainDb(this IActivityContext context)
Parameters
contextIActivityContextThe activity context.
Returns
Exceptions
- ArgumentNullException
Thrown if
contextisnull.
ETag(IActivityContext)
Retrieves the incoming ETag from the activity context.
public static string? ETag(this IActivityContext context)
Parameters
contextIActivityContextThe activity context.
Returns
- string
The incoming ETag, or
nullif not set.
Exceptions
- ArgumentNullException
Thrown if
contextisnull.
ETag(IActivityContext, string?)
Sets the outgoing ETag in the activity context.
public static void ETag(this IActivityContext context, string? newETag)
Parameters
contextIActivityContextThe activity context.
newETagstringThe new ETag to set.
Exceptions
- ArgumentNullException
Thrown if
contextisnull.
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
contextIActivityContextThe activity context.
keystringThe key associated with the value.
Returns
- T
The value associated with the key, or
nullif not found.
Type Parameters
TThe type of the value to retrieve.
Exceptions
- ArgumentNullException
Thrown if
contextisnull.
LatestETag(IActivityContext)
Retrieves the most recent ETag (outgoing if set, otherwise incoming) from the activity context.
public static string? LatestETag(this IActivityContext context)
Parameters
contextIActivityContextThe activity context.
Returns
- string
The latest ETag, or
nullif not set.
Exceptions
- ArgumentNullException
Thrown if
contextisnull.
ServiceProvider(IActivityContext)
Retrieves the service provider from the activity context.
public static IServiceProvider ServiceProvider(this IActivityContext context)
Parameters
contextIActivityContextThe activity context.
Returns
- IServiceProvider
The service provider instance.
Exceptions
- ArgumentNullException
Thrown if
contextisnull.
TenantId(IActivityContext)
Retrieves the tenant ID from the activity context.
public static string? TenantId(this IActivityContext context)
Parameters
contextIActivityContextThe activity context.
Returns
- string
The tenant ID.
Exceptions
- ArgumentNullException
Thrown if
contextisnull.