1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-14 18:02:58 +00:00

Added copy for option objects, socket message handlers can now return whether they handled the message

This commit is contained in:
JKorf
2018-11-28 11:14:32 +01:00
parent 9648606bdc
commit 596b28dd47
3 changed files with 46 additions and 5 deletions
+37 -1
View File
@@ -36,7 +36,7 @@ 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
@@ -55,6 +55,25 @@ namespace CryptoExchange.Net.Objects
/// The time the server has to respond to a request before timing out
/// </summary>
public TimeSpan RequestTimeout { get; set; } = TimeSpan.FromSeconds(30);
public T Copy<T>() where T:ClientOptions, new()
{
var copy = new T
{
BaseAddress = BaseAddress,
LogVerbosity = LogVerbosity,
Proxy = Proxy,
LogWriters = LogWriters,
RateLimiters = RateLimiters,
RateLimitingBehaviour = RateLimitingBehaviour,
RequestTimeout = RequestTimeout
};
if (ApiCredentials != null)
copy.ApiCredentials = new ApiCredentials(ApiCredentials.Key.GetString(), ApiCredentials.Secret.GetString());
return copy;
}
}
public class SocketClientOptions: ExchangeOptions
@@ -63,5 +82,22 @@ namespace CryptoExchange.Net.Objects
/// Time to wait between reconnect attempts
/// </summary>
public TimeSpan ReconnectInterval { get; set; } = TimeSpan.FromSeconds(5);
public T Copy<T>() where T : SocketClientOptions, new()
{
var copy = new T
{
BaseAddress = BaseAddress,
LogVerbosity = LogVerbosity,
Proxy = Proxy,
LogWriters = LogWriters,
ReconnectInterval = ReconnectInterval
};
if (ApiCredentials != null)
copy.ApiCredentials = new ApiCredentials(ApiCredentials.Key.GetString(), ApiCredentials.Secret.GetString());
return copy;
}
}
}