public
Last active

Response/Option

  • Download Gist
Response.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
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();
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.