| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | using System;using Renci.SshNet.Sftp.Responses;namespace Renci.SshNet.Sftp.Requests{    internal class SftpWriteRequest : SftpRequest    {        public override SftpMessageTypes SftpMessageType        {            get { return SftpMessageTypes.Write; }        }        public byte[] Handle { get; private set; }        public UInt64 Offset { get; private set; }        public byte[] Data { get; private set; }#if TUNING        public int Length { get; private set; }        protected override int BufferCapacity        {            get            {                var capacity = base.BufferCapacity;                capacity += 4; // Handle length                capacity += Handle.Length; // Handle                capacity += 8; // Offset length                capacity += 4; // Data length                capacity += Length; // Data                return capacity;            }        }#endif        public SftpWriteRequest(uint protocolVersion,                                uint requestId,                                byte[] handle,                                UInt64 offset,                                byte[] data,#if TUNING                                int length,#endif                                Action<SftpStatusResponse> statusAction)            : base(protocolVersion, requestId, statusAction)        {            this.Handle = handle;            this.Offset = offset;            this.Data = data;#if TUNING            this.Length = length;#endif        }        protected override void LoadData()        {            base.LoadData();#if TUNING            this.Handle = this.ReadBinary();#else            this.Handle = this.ReadBinaryString();#endif            this.Offset = this.ReadUInt64();#if TUNING            this.Data = this.ReadBinary();#else            this.Data = this.ReadBinaryString();#endif#if TUNING            this.Length = this.Data.Length;#endif        }        protected override void SaveData()        {            base.SaveData();            this.WriteBinaryString(this.Handle);            this.Write(this.Offset);#if TUNING            this.WriteBinary(this.Data, 0, Length);#else            this.WriteBinaryString(this.Data);#endif        }    }}
 |