Skip to content

Commit e54e049

Browse files
author
Vadim Belov
committed
Add XML docs and cleanup to mediator core interfaces/classes
Extensive XML documentation was added to all major mediator interfaces and classes, improving code readability and IDE support. Updated using directives for EasyExtensions.Mediator.Contracts across files. Replaced static lambdas in ConcurrentDictionary.GetOrAdd with non-static versions for compatibility. Removed TypeForwardings.cs and related type forwarding attributes. Made minor code style improvements and clarified dependencies. No functional changes to mediator logic.
1 parent f374a30 commit e54e049

13 files changed

Lines changed: 258 additions & 47 deletions

Sources/EasyExtensions.Mediator/IMediator.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@ namespace EasyExtensions.Mediator
33
/// <summary>
44
/// Defines a mediator to encapsulate request/response and publishing interaction patterns
55
/// </summary>
6-
public interface IMediator : ISender, IPublisher
7-
{
8-
}
6+
public interface IMediator : ISender, IPublisher { }
97
}

Sources/EasyExtensions.Mediator/INotificationHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using EasyExtensions.Mediator.Contracts;
12
using System.Threading;
23
using System.Threading.Tasks;
34

Sources/EasyExtensions.Mediator/INotificationPublisher.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,21 @@
55

66
namespace EasyExtensions.Mediator
77
{
8+
/// <summary>
9+
/// Defines a contract for publishing notifications to one or more notification handler executors asynchronously.
10+
/// </summary>
11+
/// <remarks>Implementations of this interface are responsible for invoking the provided notification
12+
/// handler executors with the specified notification. The publishing process is typically asynchronous and may
13+
/// involve invoking handlers in parallel or sequentially, depending on the implementation.</remarks>
814
public interface INotificationPublisher
915
{
16+
/// <summary>
17+
/// Publishes a notification to the specified handler executors asynchronously.
18+
/// </summary>
19+
/// <param name="handlerExecutors">A collection of handler executors that will process the notification. Cannot be null.</param>
20+
/// <param name="notification">The notification instance to be published. Cannot be null.</param>
21+
/// <param name="cancellationToken">A token that can be used to cancel the publish operation.</param>
22+
/// <returns>A task that represents the asynchronous publish operation.</returns>
1023
Task Publish(IEnumerable<NotificationHandlerExecutor> handlerExecutors, INotification notification,
1124
CancellationToken cancellationToken);
1225
}

Sources/EasyExtensions.Mediator/IPublisher.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading;
1+
using EasyExtensions.Mediator.Contracts;
2+
using System.Threading;
23
using System.Threading.Tasks;
34

45
namespace EasyExtensions.Mediator

Sources/EasyExtensions.Mediator/IRequestHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using EasyExtensions.Mediator.Contracts;
12
using System.Threading;
23
using System.Threading.Tasks;
34

Sources/EasyExtensions.Mediator/ISender.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using EasyExtensions.Mediator.Contracts;
2+
using System.Collections.Generic;
23
using System.Threading;
34
using System.Threading.Tasks;
45

Sources/EasyExtensions.Mediator/IStreamRequestHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using EasyExtensions.Mediator.Contracts;
12
using System.Collections.Generic;
23
using System.Threading;
34

Sources/EasyExtensions.Mediator/Mediator.cs

Lines changed: 94 additions & 31 deletions
Large diffs are not rendered by default.

Sources/EasyExtensions.Mediator/NotificationHandlerExecutor.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,33 @@
55

66
namespace EasyExtensions.Mediator
77
{
8+
/// <summary>
9+
/// Encapsulates a notification handler instance and its associated execution callback.
10+
/// </summary>
11+
/// <remarks>This class is typically used to store and invoke notification handlers in a decoupled manner,
12+
/// allowing for flexible execution of notification processing logic. It is commonly used in messaging or
13+
/// event-driven architectures where notifications are dispatched to multiple handlers.</remarks>
814
public class NotificationHandlerExecutor
915
{
16+
/// <summary>
17+
/// Gets the instance of the handler associated with this object.
18+
/// </summary>
1019
public object HandlerInstance { get; }
11-
public Func<INotification, CancellationToken, Task> HandlerCallback { get; }
1220

21+
/// <summary>
22+
/// Gets the callback function that handles incoming notifications asynchronously.
23+
/// </summary>
24+
/// <remarks>The callback is invoked with the notification to process and a cancellation token
25+
/// that can be used to observe cancellation requests. The function should return a task that completes when the
26+
/// notification has been handled.</remarks>
27+
public Func<INotification, CancellationToken, Task> HandlerCallback { get; }
1328

29+
/// <summary>
30+
/// Initializes a new instance of the NotificationHandlerExecutor class with the specified handler instance and
31+
/// callback.
32+
/// </summary>
33+
/// <param name="handlerInstance">The object instance that contains the notification handler logic. Cannot be null.</param>
34+
/// <param name="handlerCallback">A delegate that represents the asynchronous callback to invoke when handling a notification. Cannot be null.</param>
1435
public NotificationHandlerExecutor(object handlerInstance, Func<INotification, CancellationToken, Task> handlerCallback)
1536
{
1637
HandlerInstance = handlerInstance;

Sources/EasyExtensions.Mediator/Registration/ServiceRegistrar.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,25 @@ private static (Type Service, Type Implementation) GetConcreteRegistrationTypes(
285285
return combinations.Select(types => requestGenericTypeDefinition.MakeGenericType(types.ToArray())).ToList();
286286
}
287287

288-
// Method to generate combinations recursively
288+
/// <summary>
289+
/// Generates all possible combinations by selecting one type from each list of types, producing a list of type
290+
/// combinations suitable for generic type construction.
291+
/// </summary>
292+
/// <remarks>This method is typically used to generate all possible sets of type arguments for a
293+
/// generic type, given multiple candidate types for each parameter. The number of combinations grows
294+
/// multiplicatively with the size of the input lists, so use caution with large inputs. The operation can be
295+
/// cancelled via the provided cancellation token.</remarks>
296+
/// <param name="requestType">The generic type definition for which combinations are being generated. Used for validation and exception
297+
/// messages.</param>
298+
/// <param name="lists">A list of lists, where each inner list contains possible types for a corresponding generic type parameter.
299+
/// Each combination will select one type from each inner list.</param>
300+
/// <param name="depth">The current recursion depth. This parameter is used internally and should typically be left at its default
301+
/// value.</param>
302+
/// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
303+
/// <returns>A list of combinations, where each combination is a list of types representing one possible selection of
304+
/// types from the input lists. The result will be empty if any input list is empty.</returns>
305+
/// <exception cref="ArgumentException">Thrown if the number of generic type parameters exceeds the allowed maximum, if any inner list exceeds the
306+
/// allowed maximum length, or if the total number of combinations exceeds the allowed maximum.</exception>
289307
public static List<List<Type>> GenerateCombinations(Type requestType, List<List<Type>> lists, int depth = 0, CancellationToken cancellationToken = default)
290308
{
291309
if (depth == 0)

0 commit comments

Comments
 (0)