Funktion: Erweiterung von IServiceMessage mit Methoden zur Nachrichtenverwaltung
- Hinzufügen von Erweiterungsmethoden zu IServiceMessage für das Hinzufügen von Client-, Trace-, Debug-, Informations-, Warn-, Fehler- und kritischen Nachrichten. - Einbeziehung von Methoden für direkte Nachrichten und auf Enum basierende Schlüssel, die Lokalisierung und benutzerdefinierte Formatierung unterstützen.
This commit is contained in:
@@ -9,17 +9,47 @@ namespace DigitalData.Core.Application
|
||||
/// <typeparam name="T">The type of data returned by the service operation, if any.</typeparam>
|
||||
public class ServiceResult<T> : ServiceMessage, IServiceResult<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ServiceResult class.
|
||||
public ServiceResult()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ServiceResult class, specifying the success status is false and data.
|
||||
/// Optionally, a function for translating message keys can be provided.
|
||||
/// If a translation function is provided, it will be used for both string and enum message keys.
|
||||
/// </summary>
|
||||
/// <param name="data">The data associated with a successful operation.</param>
|
||||
/// <param name="stringKeyTranslator">A function that translates a string key into its localized representation.
|
||||
/// If provided, it will also be adapted for translating enum keys by converting them to strings first.</param>
|
||||
[Obsolete("Deprecated: initialize objects using object initializers instead.")]
|
||||
public ServiceResult(T? data)
|
||||
{
|
||||
Data = data;
|
||||
IsSuccess = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ServiceResult class with specified success status and data.
|
||||
/// </summary>
|
||||
/// <param name="data">The data associated with a successful operation.</param>
|
||||
/// <param name="isSuccess">Indicates whether the service operation was successful.</param>
|
||||
[Obsolete("Deprecated: initialize objects using object initializers instead.")]
|
||||
public ServiceResult(T? data, bool isSuccess) : base(isSuccess) => Data = data;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ServiceResult class with specified success status, data, and messages.
|
||||
/// </summary>
|
||||
/// <param name="data">The data associated with a successful operation.</param>
|
||||
/// <param name="isSuccess">Indicates whether the service operation was successful.</param>
|
||||
/// <param name="messages">An array of messages related to the operation's outcome.</param>
|
||||
[Obsolete("Deprecated: Use ClientMessages instead.")]
|
||||
public ServiceResult(T? data, bool isSuccess, params string[] messages) : base(isSuccess, messages) => Data = data;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the data resulting from the service operation.
|
||||
/// </summary>
|
||||
public T? Data { get; set; }
|
||||
public T? Data { get; set; } = default;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user