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