1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-13 09:23:04 +00:00

Added GetResultOrError on CallResult for nullability

This commit is contained in:
JKorf
2020-10-07 09:23:42 +02:00
parent 48a2c095a4
commit 9da7683291
2 changed files with 175 additions and 0 deletions
+24
View File
@@ -42,6 +42,30 @@ namespace CryptoExchange.Net.Objects
{
return obj?.Success == true;
}
/// <summary>
/// Whether the call was successful or not. Useful for nullability checking.
/// </summary>
/// <param name="data">The data returned by the call.</param>
/// <param name="error"><see cref="Error"/> on failure.</param>
/// <returns><c>true</c> when <see cref="CallResult{T}"/> succeeded, <c>false</c> otherwise.</returns>
public bool GetResultOrError([MaybeNullWhen(false)] out T data, [NotNullWhen(false)] out Error? error)
{
if (Success)
{
data = Data!;
error = null;
return true;
}
else
{
data = default;
error = Error!;
return false;
}
}
}
/// <summary>