-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Youssef Sellami edited this page Jul 24, 2021
·
12 revisions
#Result.Net
the Result object is very simple and has a few properties.
public partial class Result
{
/// <summary>
/// get the Status of the result.
/// </summary>
public ResultStatus Status { get; }
/// <summary>
/// get or set the message that describes the result of the operation.
/// </summary>
public string Message { get; set; }
/// <summary>
/// get or set the error code that describes the result of the operation.
/// </summary>
public string Code { get; set; }
/// <summary>
/// get or set a unique log trace code used to trace the result in logs.
/// </summary>
public string LogTraceCode { get; set; }
/// <summary>
/// get the list of errors associated with the operation result.
/// </summary>
public ICollection<ResultError> Errors { get; }
/// <summary>
/// Gets a collection of key/data pairs that provide additional
/// meta data information about the operation result.
/// </summary>
public IDictionary<string, object> MetaData { get; }
}- Result.Status:
the status property is an enum with two values: Failed & Succeed, it is used to define the Result status. - Result.Message:
the message property is used to describe the result status, we only using it if the result has a Failed status, to describe in human-readable format what went wrong. - Result.Code:
the code property is used to describe the result status, we use this property to enable machine-to-machine communication. utilizing a predefined list of error codes, I already have a predefined list of common codes (you can find them in ResultCode), and you can add your own. - Result.LogTraceCode: the log trace code property is a random unique string used as code and attached to the result operation to locate the result in your logs.
- Result.Errors:
the error collection property is used to attach a more detailed explanation in terms of errors associated with result failure. - Result.MetaData:
the metadata property is a key-value pair collection to attach some additional data with the operation result.