Created
May 27, 2010 13:10
-
-
Save jonfuller/415778 to your computer and use it in GitHub Desktop.
Response/Option
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 class Response<T> | |
{ | |
public static implicit operator bool(Response<T> response) | |
{ | |
return response.Success; | |
} | |
public bool Success { get; private set; } | |
public T Value { get; private set; } | |
public Response(bool success, T value) | |
{ | |
Success = success; | |
Value = value; | |
} | |
public void If(Action<T> success, Action notSuccess) | |
{ | |
if (Success) | |
success(Value); | |
else | |
notSuccess(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment