示例#1
0
        public override byte[] Encode()
        {
            List <byte> result = new List <byte>();

            result.Add(Type);
            result.AddRange(StreamId.ToByteArray());
            result.AddRange(MaximumStreamData.ToByteArray());

            return(result.ToArray());
        }
示例#2
0
        public override byte[] Encode()
        {
            List <byte> result = new List <byte>();

            result.Add(Type);
            result.AddRange(StreamId.ToByteArray());
            result.AddRange(ApplicationProtocolErrorCode.ToByteArray());
            result.AddRange(FinalSize.ToByteArray());

            return(result.ToArray());
        }
示例#3
0
        /// <summary>
        /// Saves metadata
        /// </summary>
        public void Save()
        {
            if (ownerStream != null && StreamTableIndex != -1)
            {
                Tools.BufferWriter.Seek(0, SeekOrigin.Begin);

                Tools.BufferWriter.Write(StreamId.ToByteArray());
                Tools.BufferWriter.Write(Length);
                Tools.BufferWriter.Write(InitializedLength);
                long firstSegmentPos = FirstSegmentPosition.HasValue ? FirstSegmentPosition.Value : (long)0;
                Tools.BufferWriter.Write(firstSegmentPos);
                Tools.BufferWriter.Write(Tag);

                int hash = Tools.CalculateHash(StreamId, Length, InitializedLength, firstSegmentPos);
                Tools.BufferWriter.Write(hash);

                ownerStream.Position = StreamTableIndex * StorageStreamMetadata.StructureSize;
                ownerStream.Write(Tools.Buffer, 0, StorageStreamMetadata.StructureSize);
            }
        }