namespace Unosquare.Swan.Models { /// /// Represents a Ok value or Error value. /// /// The type of OK value. /// The type of the error. public class OkOrError { /// /// Gets or sets a value indicating whether this instance is Ok. /// /// /// true if this instance is ok; otherwise, false. /// public bool IsOk => !Equals(Ok, default(T)); /// /// Gets or sets the ok. /// /// /// The ok. /// public T Ok { get; set; } /// /// Gets or sets the error. /// /// /// The error. /// public TError Error { get; set; } /// /// Creates a new OkOrError from the specified Ok object. /// /// The ok. /// OkOrError instance. public static OkOrError FromOk(T ok) => new OkOrError { Ok = ok }; /// /// Creates a new OkOrError from the specified Error object. /// /// The error. /// OkOrError instance. public static OkOrError FromError(TError error) => new OkOrError { Error = error }; } }