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

Initial v2 changes

This commit is contained in:
Jan Korf
2018-11-22 12:45:36 +01:00
parent c558f25b6c
commit 5c63941f32
13 changed files with 618 additions and 240 deletions
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
namespace CryptoExchange.Net.Objects
{
public class ByteOrderComparer : IComparer<byte[]>
{
public int Compare(byte[] x, byte[] y)
{
// Shortcuts: If both are null, they are the same.
if (x == null && y == null) return 0;
// If one is null and the other isn't, then the
// one that is null is "lesser".
if (x == null && y != null) return -1;
if (x != null && y == null) return 1;
// Both arrays are non-null. Find the shorter
// of the two lengths.
int bytesToCompare = Math.Min(x.Length, y.Length);
// Compare the bytes.
for (int index = 0; index < bytesToCompare; ++index)
{
// The x and y bytes.
byte xByte = x[index];
byte yByte = y[index];
// Compare result.
int compareResult = Comparer<byte>.Default.Compare(xByte, yByte);
// If not the same, then return the result of the
// comparison of the bytes, as they were the same
// up until now.
if (compareResult != 0) return compareResult;
// They are the same, continue.
}
// The first n bytes are the same. Compare lengths.
// If the lengths are the same, the arrays
// are the same.
if (x.Length == y.Length) return 0;
// Compare lengths.
return x.Length < y.Length ? -1 : 1;
}
}
}
+13
View File
@@ -0,0 +1,13 @@
namespace CryptoExchange.Net.Objects
{
public class Constants
{
public const string GetMethod = "GET";
public const string PostMethod = "POST";
public const string DeleteMethod = "DELETE";
public const string PutMethod = "PUT";
public const string JsonContentHeader = "application/json";
public const string FormContentHeader = "application/x-www-form-urlencoded";
}
}
+14 -2
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Logging;
@@ -35,8 +36,11 @@ namespace CryptoExchange.Net.Objects
/// <summary>
/// The log writers
/// </summary>
public List<TextWriter> LogWriters { get; set; } = new List<TextWriter>() {new DebugTextWriter()};
public List<TextWriter> LogWriters { get; set; } = new List<TextWriter>() {new DebugTextWriter()};
}
public class ClientOptions: ExchangeOptions
{
/// <summary>
/// List of ratelimiters to use
/// </summary>
@@ -47,4 +51,12 @@ namespace CryptoExchange.Net.Objects
/// </summary>
public RateLimitingBehaviour RateLimitingBehaviour { get; set; } = RateLimitingBehaviour.Wait;
}
public class SocketClientOptions: ExchangeOptions
{
/// <summary>
/// Time to wait between reconnect attempts
/// </summary>
public TimeSpan ReconnectInterval { get; set; } = TimeSpan.FromSeconds(2);
}
}