using CryptoExchange.Net.Objects; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CryptoExchange.Net.SharedApis { /// /// Client information /// public class SharedClientInfo { private CapabilityOptions[] _capabilities = []; /// /// Exchange name /// public string Exchange { get; init; } = string.Empty; /// /// The client type name /// public string TypeName { get; init; } = string.Empty; /// /// Environments supported by this client /// public string[] SupportedEnvironments { get; set; } = []; /// /// Supported trading modes /// public TradingMode[] SupportedTradingModes { get; init; } = []; /// /// Centralization type of the exchange /// public CentralizationType CentralizationType { get; set; } /// /// Use Capabilities instead /// [Obsolete("Use Capabilities instead")] public EndpointOptions[] Features { get => _capabilities .OfType() .ToArray(); init => _capabilities = value; } /// /// Client capabilities /// public CapabilityOptions[] Capabilities { get => _capabilities; init => _capabilities = value; } /// /// Create a string representation for this client /// public override string ToString() => ToString(false); /// /// Create a string representation for this client /// public string ToString(bool detailed) { var sb = new StringBuilder(); sb.AppendLine($"Exchange: {Exchange}"); sb.AppendLine($"Client: {TypeName}"); sb.AppendLine($"Supported environments: {string.Join(", ", SupportedEnvironments)}"); sb.AppendLine($"Supported trading modes: {string.Join(", ", SupportedTradingModes)}"); sb.AppendLine($"Centralization type: {CentralizationType}"); sb.AppendLine($"Capabilities:"); foreach (var capability in Capabilities) { if (detailed) { var stringRep = capability.ToString(); foreach(var line in stringRep!.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) sb.AppendLine($" {line}"); } else { sb.AppendLine($" {capability.OperationName}"); } sb.AppendLine(); } return sb.ToString(); } } }