Created
January 11, 2014 20:07
-
-
Save scichelli/8376021 to your computer and use it in GitHub Desktop.
This file contains 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 class Result<T> | |
{ | |
public bool IsSuccess { get; private set; } | |
public string ErrorMessage { get; private set; } | |
public IEnumerable<T> Results { get; private set; } | |
private Result() | |
{ } | |
public static Result<T> Success(IEnumerable<T> results) | |
{ | |
return new Result<T> | |
{ | |
IsSuccess = true, | |
Results = results | |
}; | |
} | |
public static Result<T> Success(T result) | |
{ | |
return Success(new[] { result }); | |
} | |
public static Result<T> Error(int statusCode, string reasonPhrase) | |
{ | |
return new Result<T> | |
{ | |
ErrorMessage = string.Format("Error {0}: {1}", statusCode, reasonPhrase), | |
Results = Enumerable.Empty<T>() | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment