| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | using System;using Renci.SshNet.Sftp.Responses;namespace Renci.SshNet.Sftp.Requests{    internal class SftpReadRequest : SftpRequest    {        public override SftpMessageTypes SftpMessageType        {            get { return SftpMessageTypes.Read; }        }        public byte[] Handle { get; private set; }        public UInt64 Offset { get; private set; }        public UInt32 Length { get; private set; }#if TUNING        /// <summary>        /// Gets the size of the message in bytes.        /// </summary>        /// <value>        /// The size of the messages in bytes.        /// </value>        protected override int BufferCapacity        {            get            {                var capacity = base.BufferCapacity;                capacity += 4; // Handle length                capacity += Handle.Length; // Handle                capacity += 8; // Offset                capacity += 4; // Length                return capacity;            }        }#endif        public SftpReadRequest(uint protocolVersion, uint requestId, byte[] handle, UInt64 offset, UInt32 length, Action<SftpDataResponse> dataAction, Action<SftpStatusResponse> statusAction)            : base(protocolVersion, requestId, statusAction)        {            this.Handle = handle;            this.Offset = offset;            this.Length = length;            this.SetAction(dataAction);        }        protected override void LoadData()        {            base.LoadData();#if TUNING            this.Handle = this.ReadBinary();#else            this.Handle = this.ReadBinaryString();#endif            this.Offset = this.ReadUInt64();            this.Length = this.ReadUInt32();        }        protected override void SaveData()        {            base.SaveData();            this.WriteBinaryString(this.Handle);            this.Write(this.Offset);            this.Write(this.Length);        }    }}
 |