namespace StockSharp.Community { using System; using System.Runtime.Serialization; using Ecng.Common; using StockSharp.Messages; /// /// File info message. /// [DataContract] [Serializable] public class FileInfoMessage : BaseSubscriptionIdMessage, ITransactionIdMessage { /// /// Initializes a new instance of the . /// public FileInfoMessage() : this(CommunityMessageTypes.FileInfo) { } /// /// Initializes a new instance of the . /// /// Message type. protected FileInfoMessage(MessageTypes type) : base(type) { } /// [DataMember] public long TransactionId { get; set; } /// /// File name. /// [DataMember] public string FileName { get; set; } /// /// File body length. /// [DataMember] public long BodyLength { get; set; } /// /// File body. /// [DataMember] public byte[] Body { get; set; } /// /// Identifier. /// [DataMember] public long Id { get; set; } /// /// Group ID. /// [DataMember] public long GroupId { get; set; } /// /// Is the file available for public. /// [DataMember] public bool IsPublic { get; set; } /// /// File url. /// [DataMember] public string Url { get; set; } /// /// File hash. /// [DataMember] public string Hash { get; set; } /// /// Date of creation. /// [DataMember] public DateTime CreationDate { get; set; } /// public override DataType DataType => DataType.Create(typeof(FileInfoMessage), null); /// /// Copy the message into the . /// /// The object, to which copied information. public override void CopyTo(FileInfoMessage destination) { base.CopyTo(destination); destination.TransactionId = TransactionId; destination.FileName = FileName; destination.BodyLength = BodyLength; destination.Body = Body; destination.Id = Id; destination.GroupId = GroupId; destination.IsPublic = IsPublic; destination.Url = Url; destination.Hash = Hash; destination.CreationDate = CreationDate; } /// /// Create a copy of . /// /// Copy. public override Message Clone() { var clone = new FileInfoMessage(); CopyTo(clone); return clone; } /// /// Get body length. /// /// File body length. public long GetBodyLength() => Body?.Length ?? BodyLength; /// public override string ToString() { var str = base.ToString(); if (TransactionId > 0) str += $",TrId={TransactionId}"; str += $",BodyLen={GetBodyLength()}"; if (!FileName.IsEmpty()) str += $",FileName={FileName}"; if (Id != 0) str += $",Id={Id}"; if (GroupId != 0) str += $",Id={GroupId}"; if (IsPublic) str += $",Public={IsPublic}"; if (!Url.IsEmpty()) str += $",Url={Url}"; if (!Hash.IsEmpty()) str += $",Hash={Hash}"; if (CreationDate != default) str += $",Created={CreationDate}"; return str; } } }