Created
July 5, 2019 04:43
-
-
Save SchreinerK/4897a352be6e59db340b40d4422747ed to your computer and use it in GitHub Desktop.
Result<Value>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Result<TValue> | |
{ | |
internal Result(TValue value, bool success, object failureInfo) | |
{ | |
Value = value; | |
Success = success; | |
FailureInfo = failureInfo; | |
} | |
public TValue Value { get; private set; } | |
public bool Success { get; private set; } | |
public bool Failed => !Success; | |
public object FailureInfo { get; private set; } | |
} | |
public static class Result | |
{ | |
public static Result<TValue> Success<TValue>(TValue value) => new Result<TValue>(value, true, null); | |
public static Result<TValue> Failed<TValue>(object failureInfo) => new Result<TValue>(default(TValue), false, failureInfo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment