protected override void ProtectedImport(Stream stream, BufferManager bufferManager, int count) { 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.Nickname) { this.Nickname = ItemUtilities.GetString(rangeStream); } else if (id == (byte)SerializeId.DigitalSignatureAlgorithm) { this.DigitalSignatureAlgorithm = (DigitalSignatureAlgorithm)Enum.Parse(typeof(DigitalSignatureAlgorithm), ItemUtilities.GetString(rangeStream)); } else if (id == (byte)SerializeId.PublicKey) { this.PublicKey = ItemUtilities.GetByteArray(rangeStream); } else if (id == (byte)SerializeId.PrivateKey) { this.PrivateKey = ItemUtilities.GetByteArray(rangeStream); } } } }
protected override void ProtectedImport(Stream stream, BufferManager bufferManager, int count) { 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.CreationTime) { this.CreationTime = DateTime.ParseExact(ItemUtilities.GetString(rangeStream), "yyyy-MM-ddTHH:mm:ssZ", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToUniversalTime(); } else if (id == (byte)SerializeId.ExchangeAlgorithm) { this.ExchangeAlgorithm = (ExchangeAlgorithm)Enum.Parse(typeof(ExchangeAlgorithm), ItemUtilities.GetString(rangeStream)); } else if (id == (byte)SerializeId.PublicKey) { this.PublicKey = ItemUtilities.GetByteArray(rangeStream); } else if (id == (byte)SerializeId.PrivateKey) { this.PrivateKey = ItemUtilities.GetByteArray(rangeStream); } } } }