mirror of
https://github.com/StockSharp/StockSharp.git
synced 2026-12-06 01:22:11 +00:00
137 lines
3.1 KiB
C#
137 lines
3.1 KiB
C#
namespace StockSharp.Messages;
|
|
|
|
/// <summary>
|
|
/// <see cref="Message"/> offline modes.
|
|
/// </summary>
|
|
public enum MessageOfflineModes
|
|
{
|
|
/// <summary>
|
|
/// None.
|
|
/// </summary>
|
|
[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.NoneKey)]
|
|
None,
|
|
|
|
/// <summary>
|
|
/// Ignore offline mode and continue processing.
|
|
/// </summary>
|
|
[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.IgnoreKey)]
|
|
Ignore,
|
|
|
|
/// <summary>
|
|
/// Cancel message processing and create reply.
|
|
/// </summary>
|
|
[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.CancelKey)]
|
|
Cancel,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Message loopback modes.
|
|
/// </summary>
|
|
public enum MessageBackModes
|
|
{
|
|
/// <summary>
|
|
/// None.
|
|
/// </summary>
|
|
[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.NoneKey)]
|
|
None,
|
|
|
|
/// <summary>
|
|
/// Direct.
|
|
/// </summary>
|
|
[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.DirectKey)]
|
|
Direct,
|
|
|
|
/// <summary>
|
|
/// Via whole adapters chain.
|
|
/// </summary>
|
|
[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.AdapterChainKey)]
|
|
Chain,
|
|
}
|
|
|
|
/// <summary>
|
|
/// A message containing market data or command.
|
|
/// </summary>
|
|
[DataContract]
|
|
[Serializable]
|
|
public abstract class Message : Cloneable<Message>, IMessage
|
|
{
|
|
/// <inheritdoc />
|
|
[Display(
|
|
ResourceType = typeof(LocalizedStrings),
|
|
Name = LocalizedStrings.LocalTimeKey,
|
|
Description = LocalizedStrings.LocalTimeDescKey,
|
|
GroupName = LocalizedStrings.GeneralKey)]
|
|
[DataMember]
|
|
public DateTime LocalTime { get; set; }
|
|
|
|
[field: NonSerialized]
|
|
private readonly MessageTypes _type;
|
|
|
|
/// <inheritdoc />
|
|
public MessageTypes Type => _type;
|
|
|
|
/// <inheritdoc />
|
|
[XmlIgnore]
|
|
public MessageBackModes BackMode { get; set; }
|
|
|
|
/// <summary>
|
|
/// Offline mode handling message.
|
|
/// </summary>
|
|
[XmlIgnore]
|
|
public MessageOfflineModes OfflineMode { get; set; }
|
|
|
|
/// <inheritdoc />
|
|
[XmlIgnore]
|
|
public IMessageAdapter Adapter { get; set; }
|
|
|
|
/// <summary>
|
|
/// Initialize <see cref="Message"/>.
|
|
/// </summary>
|
|
/// <param name="type">Message type.</param>
|
|
protected Message(MessageTypes type)
|
|
{
|
|
_type = type;
|
|
#if MSG_TRACE
|
|
StackTrace = Environment.StackTrace;
|
|
#endif
|
|
}
|
|
|
|
#if MSG_TRACE
|
|
internal string StackTrace;
|
|
#endif
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString()
|
|
{
|
|
var str = Type + $",T(L)={LocalTime:yyyy/MM/dd HH:mm:ss.fff}";
|
|
|
|
if (BackMode != default)
|
|
str += $",Back={BackMode}";
|
|
|
|
if (OfflineMode != default)
|
|
str += $",Offline={OfflineMode}";
|
|
|
|
return str;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a copy of <see cref="Message"/>.
|
|
/// </summary>
|
|
/// <returns>Copy.</returns>
|
|
public abstract override Message Clone();
|
|
|
|
/// <summary>
|
|
/// Copy the message into the <paramref name="destination" />.
|
|
/// </summary>
|
|
/// <param name="destination">The object, to which copied information.</param>
|
|
protected void CopyTo(Message destination)
|
|
{
|
|
if (destination == null)
|
|
throw new ArgumentNullException(nameof(destination));
|
|
|
|
destination.LocalTime = LocalTime;
|
|
#if MSG_TRACE
|
|
destination.StackTrace = StackTrace;
|
|
#endif
|
|
}
|
|
} |