Class ActivityContext
- Namespace
- Excalibur.Application
- Assembly
- Excalibur.Application.dll
Represents a context for managing activity-related data within an application.
public sealed class ActivityContext : IActivityContext
- Inheritance
-
ActivityContext
- Implements
- Inherited Members
- Extension Methods
Constructors
ActivityContext(string, ICorrelationId, IETag, IConfiguration, IClientAddress, IServiceProvider)
Initializes a new instance of the ActivityContext class with essential dependencies.
public ActivityContext(string tenantId, ICorrelationId correlationId, IETag eTag, IConfiguration configuration, IClientAddress clientAddress, IServiceProvider serviceProvider)
Parameters
tenantIdstringThe resolved tenant identifier value.
correlationIdICorrelationIdThe correlation identifier.
eTagIETagThe ETag for concurrency control.
configurationIConfigurationThe application configuration.
clientAddressIClientAddressThe client address.
serviceProviderIServiceProviderThe service provider for dependency Excalibur.Tests.Integration.
Methods
ContainsKey(string)
Checks if the context contains a value for the specified key.
public bool ContainsKey(string key)
Parameters
keystringThe key to check for existence in the context.
Returns
- bool
trueif the key exists in the context; otherwise,false.
GetValue<T>(string, T)
Retrieves a value from the context by its key, or returns a default value if the key is not found.
public T GetValue<T>(string key, T defaultValue)
Parameters
keystringThe key associated with the value to retrieve.
defaultValueTThe default value to return if the key does not exist or the value is
null.
Returns
- T
The value associated with the specified key, or
defaultValueif the key does not exist.
Type Parameters
TThe type of the value to retrieve.
Exceptions
- ArgumentException
Thrown if
keyisnull, empty, or whitespace.
Remove(string)
Removes a value from the context for the specified key.
public void Remove(string key)
Parameters
keystringThe key associated with the value to remove.
Exceptions
- ArgumentException
Thrown if
keyisnull, empty, or whitespace.
SetValue<T>(string, T)
Sets a value in the context for the specified key.
public void SetValue<T>(string key, T value)
Parameters
keystringThe key to associate with the value.
valueTThe value to store in the context.
Type Parameters
TThe type of the value to set.
Exceptions
- ArgumentException
Thrown if
keyisnull, empty, or whitespace.