1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 16:06:15 +00:00

Fixed DataTime copying in DataEvent

This commit is contained in:
Jkorf 2025-02-10 14:32:25 +01:00
parent d2a87a1069
commit a258532d6a
2 changed files with 19 additions and 6 deletions

View File

@ -15,7 +15,7 @@ namespace CryptoExchange.Net.Objects.Sockets
public DateTime ReceiveTime { get; set; } public DateTime ReceiveTime { get; set; }
/// <summary> /// <summary>
/// The timestamp of the data as specified by the server /// The timestamp of the data as specified by the server. Note that the server time and client time might not be 100% in sync so this value might not be fully comparable to local time.
/// </summary> /// </summary>
public DateTime? DataTime { get; set; } public DateTime? DataTime { get; set; }
@ -65,7 +65,10 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <returns></returns> /// <returns></returns>
public DataEvent<K> As<K>(K data) public DataEvent<K> As<K>(K data)
{ {
return new DataEvent<K>(data, StreamId, Symbol, OriginalData, ReceiveTime, UpdateType); return new DataEvent<K>(data, StreamId, Symbol, OriginalData, ReceiveTime, UpdateType)
{
DataTime = DataTime
};
} }
/// <summary> /// <summary>
@ -77,7 +80,10 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <returns></returns> /// <returns></returns>
public DataEvent<K> As<K>(K data, string? symbol) public DataEvent<K> As<K>(K data, string? symbol)
{ {
return new DataEvent<K>(data, StreamId, symbol, OriginalData, ReceiveTime, UpdateType); return new DataEvent<K>(data, StreamId, symbol, OriginalData, ReceiveTime, UpdateType)
{
DataTime = DataTime
};
} }
/// <summary> /// <summary>
@ -91,7 +97,10 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <returns></returns> /// <returns></returns>
public DataEvent<K> As<K>(K data, string streamId, string? symbol, SocketUpdateType updateType) public DataEvent<K> As<K>(K data, string streamId, string? symbol, SocketUpdateType updateType)
{ {
return new DataEvent<K>(data, streamId, symbol, OriginalData, ReceiveTime, updateType); return new DataEvent<K>(data, streamId, symbol, OriginalData, ReceiveTime, updateType)
{
DataTime = DataTime
};
} }
/// <summary> /// <summary>
@ -103,7 +112,10 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <returns></returns> /// <returns></returns>
public ExchangeEvent<K> AsExchangeEvent<K>(string exchange, K data) public ExchangeEvent<K> AsExchangeEvent<K>(string exchange, K data)
{ {
return new ExchangeEvent<K>(exchange, this.As<K>(data)); return new ExchangeEvent<K>(exchange, this.As<K>(data))
{
DataTime = DataTime
};
} }
/// <summary> /// <summary>
@ -142,7 +154,7 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <summary> /// <summary>
/// Specify the data timestamp /// Specify the data timestamp
/// </summary> /// </summary>
public DataEvent<T> WithDataTimestamp(DateTime timestamp) public DataEvent<T> WithDataTimestamp(DateTime? timestamp)
{ {
DataTime = timestamp; DataTime = timestamp;
return this; return this;

View File

@ -24,6 +24,7 @@ namespace CryptoExchange.Net.SharedApis
evnt.ReceiveTime, evnt.ReceiveTime,
evnt.UpdateType) evnt.UpdateType)
{ {
DataTime = evnt.DataTime;
Exchange = exchange; Exchange = exchange;
} }