Fügen Sie 'ohne Nachricht' Methoden in ResponseService hinzu
Implementieren und dokumentieren Sie Dienstmethoden, die ohne zusätzliche Nachrichten funktionieren, um die Einfachheit der Schnittstelle zu verbessern.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using DigitalData.Core.Contracts.Application;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace DigitalData.Core.Application
|
||||
{
|
||||
@@ -7,16 +8,64 @@ namespace DigitalData.Core.Application
|
||||
/// </summary>
|
||||
public class ResponseService : IResponseService
|
||||
{
|
||||
|
||||
#region WITHOUT_MESSAGE
|
||||
|
||||
/// <summary>
|
||||
/// Creates a service message indicating success or failure without additional messages.
|
||||
/// </summary>
|
||||
/// <param name="isSuccess">Indicates if the operation was successful.</param>
|
||||
/// <returns>A service message reflecting the operation outcome.</returns>
|
||||
public IServiceMessage CreateMessage(bool isSuccess) => new ServiceMessage(isSuccess);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a service result containing the provided data and a success flag, without additional messages.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data included in the result.</typeparam>
|
||||
/// <param name="data">The data to include in the result.</param>
|
||||
/// <param name="isSuccess">Indicates if the operation was successful.</param>
|
||||
/// <returns>A service result with the specified data and outcome.</returns>
|
||||
public IServiceResult<T> CreateResult<T>(T? data, bool isSuccess) => new ServiceResult<T>(data, isSuccess);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a service message indicating a successful operation without additional messages.
|
||||
/// </summary>
|
||||
/// <returns>A service message indicating a successful operation.</returns>
|
||||
public IServiceMessage Successful() => CreateMessage(true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a service message indicating a failed operation without additional messages.
|
||||
/// </summary>
|
||||
/// <returns>A service message indicating a failed operation.</returns>
|
||||
public IServiceMessage Failed() => CreateMessage(false);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a successful service result with the specified data, without additional messages.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of data included in the result.</typeparam>
|
||||
/// <param name="data">The data to include in the result.</param>
|
||||
/// <returns>A successful service result containing the specified data.</returns>
|
||||
public IServiceResult<T> Successful<T>(T data) => CreateResult(data, true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a failed service result with optional data, without additional messages.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of data the service result can contain.</typeparam>
|
||||
/// <param name="data">Optional data to include in the result.</param>
|
||||
/// <returns>A failed service result, which may or may not contain the specified data.</returns>
|
||||
public IServiceResult<T> Failed<T>(T? data = default) => CreateResult(data, false);
|
||||
|
||||
#endregion
|
||||
|
||||
#region WITH_STRING_MESSAGE
|
||||
|
||||
/// <summary>
|
||||
/// Creates a service message with the specified success flag and messages.
|
||||
/// </summary>
|
||||
/// <param name="isSuccess">Indicates if the operation was successful.</param>
|
||||
/// <param name="messages">An array of messages associated with the operation.</param>
|
||||
/// <returns>A new instance of <see cref="ServiceMessage"/> reflecting the operation outcome.</returns>
|
||||
public virtual IServiceMessage CreateMessage(bool isSuccess, params string[] messages)
|
||||
{
|
||||
return new ServiceMessage(isSuccess, messages);
|
||||
}
|
||||
public virtual IServiceMessage CreateMessage(bool isSuccess, params string[] messages) => new ServiceMessage(isSuccess, messages);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a service result containing the provided data, success flag, and messages.
|
||||
@@ -26,10 +75,7 @@ namespace DigitalData.Core.Application
|
||||
/// <param name="isSuccess">Indicates if the operation was successful.</param>
|
||||
/// <param name="messages">An array of messages associated with the operation.</param>
|
||||
/// <returns>A new instance of <see cref="ServiceResult{T}"/> with the specified data and outcome.</returns>
|
||||
public virtual IServiceResult<T> CreateResult<T>(T? data = default, bool isSuccess = true, params string[] messages)
|
||||
{
|
||||
return new ServiceResult<T>(data, isSuccess, messages);
|
||||
}
|
||||
public virtual IServiceResult<T> CreateResult<T>(T? data = default, bool isSuccess = true, params string[] messages) => new ServiceResult<T>(data, isSuccess, messages);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a successful service message.
|
||||
@@ -76,6 +122,9 @@ namespace DigitalData.Core.Application
|
||||
/// and it will include the provided failure messages.</returns>
|
||||
public virtual IServiceResult<T> Failed<T>(params string[] messages) => Failed<T>(default, messages);
|
||||
|
||||
#endregion
|
||||
#region WITH_ENUM_MESSAGE
|
||||
|
||||
/// <summary>
|
||||
/// Creates a service message with the specified success flag and enumeration messages.
|
||||
/// </summary>
|
||||
@@ -134,5 +183,7 @@ namespace DigitalData.Core.Application
|
||||
/// <returns>A failed service result. The data part of the result will be set to the default value for the specified type,
|
||||
/// and it will include the provided failure messages.</returns>
|
||||
public IServiceResult<T> Failed<T>(params Enum[] messages) => Failed<T>(default(T), messages);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
@@ -45,7 +45,6 @@ E:\TekH\Visual Studio\DDWeb\WebCoreModules\DigitalData.Core.Application\obj\Debu
|
||||
E:\TekH\Visual Studio\DDWeb\WebCoreModules\DigitalData.Core.Application\obj\Debug\net7.0\refint\DigitalData.Core.Application.dll
|
||||
E:\TekH\Visual Studio\DDWeb\WebCoreModules\DigitalData.Core.Application\obj\Debug\net7.0\DigitalData.Core.Application.pdb
|
||||
E:\TekH\Visual Studio\DDWeb\WebCoreModules\DigitalData.Core.Application\obj\Debug\net7.0\ref\DigitalData.Core.Application.dll
|
||||
E:\TekH\Visual Studio\WebCoreModules\DigitalData.Core.Application\bin\Debug\net7.0\icon.png
|
||||
E:\TekH\Visual Studio\WebCoreModules\DigitalData.Core.Application\bin\Debug\net7.0\DigitalData.Core.Application.deps.json
|
||||
E:\TekH\Visual Studio\WebCoreModules\DigitalData.Core.Application\bin\Debug\net7.0\DigitalData.Core.Application.dll
|
||||
E:\TekH\Visual Studio\WebCoreModules\DigitalData.Core.Application\bin\Debug\net7.0\DigitalData.Core.Application.pdb
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user