protected override void ProtectedImport(Stream stream, BufferManager bufferManager, int count) { lock (this.ThisLock) { for (; ;) { byte id; { byte[] idBuffer = new byte[1]; if (stream.Read(idBuffer, 0, idBuffer.Length) != idBuffer.Length) { return; } id = idBuffer[0]; } int length; { byte[] lengthBuffer = new byte[4]; if (stream.Read(lengthBuffer, 0, lengthBuffer.Length) != lengthBuffer.Length) { return; } length = NetworkConverter.ToInt32(lengthBuffer); } using (RangeStream rangeStream = new RangeStream(stream, stream.Position, length, true)) { if (id == (byte)SerializeId.Key) { this.Keys.Add(Key.Import(rangeStream, bufferManager)); } else if (id == (byte)SerializeId.CorrectionAlgorithm) { this.CorrectionAlgorithm = (CorrectionAlgorithm)Enum.Parse(typeof(CorrectionAlgorithm), ItemUtilities.GetString(rangeStream)); } else if (id == (byte)SerializeId.InformationLength) { this.InformationLength = ItemUtilities.GetInt(rangeStream); } else if (id == (byte)SerializeId.BlockLength) { this.BlockLength = ItemUtilities.GetInt(rangeStream); } else if (id == (byte)SerializeId.Length) { this.Length = ItemUtilities.GetLong(rangeStream); } } } } }
protected override void ProtectedImport(Stream stream, BufferManager bufferManager, int count) { lock (this.ThisLock) { for (; ;) { byte id; { byte[] idBuffer = new byte[1]; if (stream.Read(idBuffer, 0, idBuffer.Length) != idBuffer.Length) { return; } id = idBuffer[0]; } int length; { byte[] lengthBuffer = new byte[4]; if (stream.Read(lengthBuffer, 0, lengthBuffer.Length) != lengthBuffer.Length) { return; } length = NetworkConverter.ToInt32(lengthBuffer); } using (RangeStream rangeStream = new RangeStream(stream, stream.Position, length, true)) { if (id == (byte)SerializeId.Name) { this.Name = ItemUtilities.GetString(rangeStream); } else if (id == (byte)SerializeId.Length) { this.Length = ItemUtilities.GetLong(rangeStream); } else if (id == (byte)SerializeId.CreationTime) { this.CreationTime = DateTime.ParseExact(ItemUtilities.GetString(rangeStream), "yyyy-MM-ddTHH:mm:ssZ", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToUniversalTime(); } else if (id == (byte)SerializeId.Comment) { this.Comment = ItemUtilities.GetString(rangeStream); } else if (id == (byte)SerializeId.Rank) { this.Rank = ItemUtilities.GetInt(rangeStream); } else if (id == (byte)SerializeId.Key) { this.Key = Key.Import(rangeStream, bufferManager); } else if (id == (byte)SerializeId.Keyword) { this.Keywords.Add(ItemUtilities.GetString(rangeStream)); } else if (id == (byte)SerializeId.CompressionAlgorithm) { this.CompressionAlgorithm = (CompressionAlgorithm)Enum.Parse(typeof(CompressionAlgorithm), ItemUtilities.GetString(rangeStream)); } else if (id == (byte)SerializeId.CryptoAlgorithm) { this.CryptoAlgorithm = (CryptoAlgorithm)Enum.Parse(typeof(CryptoAlgorithm), ItemUtilities.GetString(rangeStream)); } else if (id == (byte)SerializeId.CryptoKey) { this.CryptoKey = ItemUtilities.GetByteArray(rangeStream); } else if (id == (byte)SerializeId.Certificate) { this.Certificate = Certificate.Import(rangeStream, bufferManager); } } } } }