Interface IActivityContext
Defines a context for accessing activity scoped information.
public interface IActivityContext
- Extension Methods
Methods
ContainsKey(string)
Checks if the context contains a value for the specified key.
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.
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.
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.
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.