Example #1
0
            public CStream Push(string Value_)
            {
                if (_Tail + 4 + Value_.Length * 2 > _Bytes.Size)
                {
                    _Bytes.Resize(_Tail + 4 + Value_.Length * 2);
                }

                Byte[] LengthBytes = BitConverter.GetBytes(Value_.Length * 2);

                if (!BitConverter.IsLittleEndian)
                {
                    Array.Reverse(LengthBytes);
                }

                Array.Copy(LengthBytes, 0, _Bytes.Data, _Tail, 4);

                var StrBytes = Encoding.Unicode.GetBytes(Value_);

                Array.Copy(StrBytes, 0, _Bytes.Data, _Tail + 4, StrBytes.Length);

                _Tail += (4 + StrBytes.Length);

                return(this);
            }
Example #2
0
            public void Push(byte[] Data_, int Index_, int Length_)
            {
                if (Length_ <= 0)
                {
                    return;
                }

                if (_Tail + Length_ > _Bytes.Size)
                {
                    _Bytes.Resize(_Tail + Length_);
                }

                Array.Copy(Data_, Index_, _Bytes.Data, _Tail, Length_);

                _Tail += Length_;
            }