refactor: Hinzufügen der synchronen Version der Methode IsAliveAsync mit XML-Dokumentation

This commit is contained in:
tekh 2025-07-09 09:29:10 +02:00
parent f18840267d
commit 7d5c00f0cb

View File

@ -5,13 +5,28 @@ namespace Leanetec.EConnect.Client.Alive;
public static class GetExtensions
{
/// <summary>
/// Returns true if while the application is up.
/// Checks if the application is alive by sending a <see cref="GetRequest"/> via MediatR.
/// </summary>
/// <param name="mediator"></param>
/// <param name="role">Role of logged user</param>
/// <returns></returns>
public static Task<bool> IsAliveAsync(this IMediator mediator, Role? role = null, int? apiVersion = null) => mediator.Send(new GetRequest(role)
{
ApiVersion = apiVersion
});
/// <param name="mediator">The MediatR instance to send the request through.</param>
/// <param name="role">Optional role of the logged-in user.</param>
/// <param name="apiVersion">Optional API version.</param>
/// <returns>A <see cref="Task{Boolean}"/> representing whether the application is alive.</returns>
public static Task<bool> IsAliveAsync(this IMediator mediator, Role? role = null, int? apiVersion = null) =>
mediator.Send(new GetRequest(role)
{
ApiVersion = apiVersion
});
/// <summary>
/// Checks if the application is alive by sending a <see cref="GetRequest"/> synchronously via MediatR.
/// </summary>
/// <param name="mediator">The MediatR instance to send the request through.</param>
/// <param name="role">Optional role of the logged-in user.</param>
/// <param name="apiVersion">Optional API version.</param>
/// <returns>True if the application is alive; otherwise, false.</returns>
public static bool IsAlive(this IMediator mediator, Role? role = null, int? apiVersion = null) =>
mediator.Send(new GetRequest(role)
{
ApiVersion = apiVersion
}).GetAwaiter().GetResult();
}