Developer 02 124fe0787b Implementiere WithMessage und WithMessageKey Methoden in IServiceMessage
Methoden hinzugefügt, um Nachrichten direkt oder über Enum-Schlüssel hinzuzufügen, unterstützt Methodenverkettung in IServiceMessage.
2024-04-18 09:45:15 +02:00

36 lines
1.7 KiB
C#

namespace DigitalData.Core.Contracts.Application
{
/// <summary>
/// Defines a basic structure for service messages, including a success flag and a collection of messages.
/// This interface is intended to be a base for more specific service result types, offering a way to communicate
/// operation outcomes (success or failure) along with relevant messages.
/// </summary>
public interface IServiceMessage
{
/// <summary>
/// Gets or sets a value indicating whether the service operation was successful.
/// </summary>
bool IsSuccess { get; set; }
/// <summary>
/// Gets or sets a collection of messages associated with the service operation. These messages can be error descriptions,
/// success notifications, or other relevant information related to the operation's outcome.
/// </summary>
List<string> Messages { get; set; }
/// <summary>
/// Adds a new message to the collection of service messages.
/// </summary>
/// <param name="message">The message to add.</param>
/// <returns>The current instance of IServiceMessage, allowing for method chaining.</returns>
IServiceMessage WithMessage(string message);
/// <summary>
/// Adds a message corresponding to the specified message key to the collection of service messages.
/// This method uses the string representation of the enum value as the message.
/// </summary>
/// <param name="messageKey">The enum value representing the message key.</param>
/// <returns>The current instance of IServiceMessage, allowing for method chaining.</returns>
IServiceMessage WithMessageKey(Enum messageKey);
}
}