예제 #1
0
        protected override void ProtectedImport(Stream stream, BufferManager bufferManager, int depth)
        {
            using (var reader = new ItemStreamReader(stream, bufferManager))
            {
                while (reader.Available > 0)
                {
                    int id = (int)reader.GetUInt32();

                    if (id == (int)SerializeId.Depth)
                    {
                        this.Depth = (int)reader.GetUInt32();
                    }
                    else if (id == (int)SerializeId.Hash)
                    {
                        this.Hash = HashConveter.FromStream(reader.GetStream());
                    }
                }
            }
        }
예제 #2
0
        protected override Stream Export(BufferManager bufferManager, int depth)
        {
            using (var writer = new ItemStreamWriter(bufferManager))
            {
                // Depth
                if (this.Depth != 0)
                {
                    writer.Write((uint)SerializeId.Depth);
                    writer.Write((uint)this.Depth);
                }
                // Hash
                if (this.Hash != null)
                {
                    writer.Write((uint)SerializeId.Hash);
                    writer.Write(HashConveter.ToStream(this.Hash));
                }

                return(writer.GetStream());
            }
        }