using DigitalData.Core.Contracts.Application; namespace DigitalData.Core.Application { /// /// Represents the outcome of a service operation, encapsulating the success or failure status, /// the data returned by the operation, and any associated messages. /// /// The type of data returned by the service operation, if any. public class ServiceResult : ServiceMessage, IServiceResult { /// /// Initializes a new instance of the ServiceResult class. public ServiceResult() { } /// /// 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. /// /// The data associated with a successful operation. /// 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. [Obsolete("Deprecated: initialize objects using object initializers instead.")] public ServiceResult(T? data) { Data = data; IsSuccess = false; } /// /// Initializes a new instance of the ServiceResult class with specified success status and data. /// /// The data associated with a successful operation. /// Indicates whether the service operation was successful. [Obsolete("Deprecated: initialize objects using object initializers instead.")] public ServiceResult(T? data, bool isSuccess) : base(isSuccess) => Data = data; /// /// Initializes a new instance of the ServiceResult class with specified success status, data, and messages. /// /// The data associated with a successful operation. /// Indicates whether the service operation was successful. /// An array of messages related to the operation's outcome. [Obsolete("Deprecated: Use ClientMessages instead.")] public ServiceResult(T? data, bool isSuccess, params string[] messages) : base(isSuccess, messages) => Data = data; /// /// Gets or sets the data resulting from the service operation. /// public T? Data { get; set; } = default; } }