mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-11 08:22:53 +00:00
Added DebuggerDisplay Result objects
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
@@ -8,8 +9,11 @@ namespace CryptoExchange.Net.Objects;
|
||||
/// <summary>
|
||||
/// Call result
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebugView,nq}")]
|
||||
public record CallResult : ICallResult
|
||||
{
|
||||
private string DebugView => Success ? "Success" : $"Error: {Error}";
|
||||
|
||||
private static CallResult _successResult = new CallResult();
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using CryptoExchange.Net.SharedApis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
@@ -12,8 +13,11 @@ namespace CryptoExchange.Net.Objects;
|
||||
/// <summary>
|
||||
/// HTTP call result
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebugView,nq}")]
|
||||
public record HttpResult : IHttpResult
|
||||
{
|
||||
private string DebugView => $"[Req {RequestId}] " + (Success ? "Success" : $"Error: {Error}");
|
||||
|
||||
/// <summary>
|
||||
/// Create a new success HTTP result
|
||||
/// </summary>
|
||||
@@ -251,8 +255,32 @@ public record HttpResult : IHttpResult
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
[DebuggerDisplay("{DebugView,nq}")]
|
||||
public record HttpResult<T> : HttpResult, IHttpResult<T>
|
||||
{
|
||||
private string DebugView
|
||||
{
|
||||
get
|
||||
{
|
||||
var result = new StringBuilder($"[Req {RequestId}] " + (Success ? "Success" : $"Error: {Error}"));
|
||||
if (Data != null)
|
||||
{
|
||||
result.Append(", ");
|
||||
var typeName = typeof(T).Name;
|
||||
if (Data is Array ar)
|
||||
{
|
||||
result.Append($"{ar.Length} {typeName.Substring(0, typeName.Length - 2)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Append(typeName);
|
||||
}
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
@@ -8,8 +9,11 @@ namespace CryptoExchange.Net.Objects;
|
||||
/// <summary>
|
||||
/// WebSocket call result
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebugView,nq}")]
|
||||
public record WebSocketResult : IWebSocketResult
|
||||
{
|
||||
private string DebugView => $"[Sckt {ConnectionId}] " + (RequestId == null ? "" : $"[Req {RequestId}] ") + (Success ? "Success" : $"Error: {Error}");
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user