diff --git a/Changelog.md b/Changelog.md index cb6eee2..ac94250 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## v.0.24.1 +- Add `Tags` to `IExecutionContext`. + ## v.0.24.0 - Upgraded to .NET 8. diff --git a/src/Directory.Build.props b/src/Directory.Build.props index b218022..5d2b4cf 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -5,7 +5,7 @@ latest A. Shafie mediator;cqrs - 0.24.0 + 0.24.1 icon.png LiteBus is an easy-to-use and ambitious in-process mediator providing the foundation to implement Command Query Separation (CQS). It is implemented with minimal reflection and instead utilizes covariance and contravariance to provide its core functionality. https://github.com/litenova/LiteBus diff --git a/src/LiteBus.Messaging.Abstractions/Contexts/Execution/IExecutionContext.cs b/src/LiteBus.Messaging.Abstractions/Contexts/Execution/IExecutionContext.cs index 4b1c4a8..f3fc6e6 100644 --- a/src/LiteBus.Messaging.Abstractions/Contexts/Execution/IExecutionContext.cs +++ b/src/LiteBus.Messaging.Abstractions/Contexts/Execution/IExecutionContext.cs @@ -19,4 +19,9 @@ public interface IExecutionContext /// Gets a key/value collection that can be used to share data within the scope of this execution. /// IDictionary Items { get; } + + /// + /// Gets the collection of specified tags used to filter message handlers (i.e., pre, main and post) during mediation. + /// + IReadOnlyCollection Tags { get; } } \ No newline at end of file diff --git a/src/LiteBus.Messaging/Internal/Contexts/Execution/ExecutionContext.cs b/src/LiteBus.Messaging/Internal/Contexts/Execution/ExecutionContext.cs index d2484a4..f40bd0a 100644 --- a/src/LiteBus.Messaging/Internal/Contexts/Execution/ExecutionContext.cs +++ b/src/LiteBus.Messaging/Internal/Contexts/Execution/ExecutionContext.cs @@ -1,32 +1,28 @@ #nullable enable using System.Collections.Generic; +using System.Linq; using System.Threading; using LiteBus.Messaging.Abstractions; namespace LiteBus.Messaging.Internal.Contexts.Execution; -/// -/// Represents the execution context for a specific operation or task. -/// +/// internal sealed class ExecutionContext : IExecutionContext { /// /// Initializes a new instance of the class with the specified cancellation token. /// /// The cancellation token associated with the execution context. - public ExecutionContext(CancellationToken cancellationToken) + public ExecutionContext(CancellationToken cancellationToken, IEnumerable tags) { CancellationToken = cancellationToken; + Tags = tags.ToList(); } - /// - /// Gets the cancellation token associated with the execution context. - /// public CancellationToken CancellationToken { get; } - /// - /// Gets or sets a key/value collection that can be used to share data within the scope of this execution. - /// public IDictionary Items { get; } = new Dictionary(); + + public IReadOnlyCollection Tags { get; } } \ No newline at end of file diff --git a/src/LiteBus.Messaging/Internal/Mediator/MessageMediator.cs b/src/LiteBus.Messaging/Internal/Mediator/MessageMediator.cs index 0064e7f..a8d2178 100644 --- a/src/LiteBus.Messaging/Internal/Mediator/MessageMediator.cs +++ b/src/LiteBus.Messaging/Internal/Mediator/MessageMediator.cs @@ -25,7 +25,7 @@ public TMessageResult Mediate(TMessage message, var originalExecutionContext = AmbientExecutionContext.Current; // Create a new execution context for the current scope - AmbientExecutionContext.Current = new ExecutionContext(options.CancellationToken); + AmbientExecutionContext.Current = new ExecutionContext(options.CancellationToken, options.Tags); // Get the actual type of the message var messageType = message.GetType();