public static CodeLock Deserialize(Stream stream) { CodeLock codeLock = Pool.Get <CodeLock>(); CodeLock.Deserialize(stream, codeLock, false); return(codeLock); }
public CodeLock Copy() { CodeLock codeLock = Pool.Get <CodeLock>(); this.CopyTo(codeLock); return(codeLock); }
public static CodeLock DeserializeLength(Stream stream, int length) { CodeLock codeLock = Pool.Get <CodeLock>(); CodeLock.DeserializeLength(stream, length, codeLock, false); return(codeLock); }
public static CodeLock Deserialize(byte[] buffer, CodeLock instance, bool isDelta = false) { using (MemoryStream memoryStream = new MemoryStream(buffer)) { CodeLock.Deserialize(memoryStream, instance, isDelta); } return(instance); }
public virtual void WriteToStreamDelta(Stream stream, CodeLock previous) { if (previous == null) { CodeLock.Serialize(stream, this); return; } CodeLock.SerializeDelta(stream, this, previous); }
public static byte[] SerializeToBytes(CodeLock instance) { byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { CodeLock.Serialize(memoryStream, instance); array = memoryStream.ToArray(); } return(array); }
public static CodeLock Deserialize(byte[] buffer) { CodeLock codeLock = Pool.Get <CodeLock>(); using (MemoryStream memoryStream = new MemoryStream(buffer)) { CodeLock.Deserialize(memoryStream, codeLock, false); } return(codeLock); }
public static void ResetToPool(CodeLock instance) { if (!instance.ShouldPool) { return; } if (instance.pv != null) { instance.pv.ResetToPool(); instance.pv = null; } instance.hasCode = false; instance.hasGuestCode = false; Pool.Free <CodeLock>(ref instance); }
public static CodeLock DeserializeLengthDelimited(Stream stream, CodeLock instance, bool isDelta) { long position = (long)ProtocolParser.ReadUInt32(stream); position += stream.Position; while (stream.Position < position) { int num = stream.ReadByte(); if (num == -1) { throw new EndOfStreamException(); } if (num == 10) { if (instance.pv != null) { CodeLock.Private.DeserializeLengthDelimited(stream, instance.pv, isDelta); } else { instance.pv = CodeLock.Private.DeserializeLengthDelimited(stream); } } else if (num == 16) { instance.hasCode = ProtocolParser.ReadBool(stream); } else if (num == 24) { instance.hasGuestCode = ProtocolParser.ReadBool(stream); } else { Key key = ProtocolParser.ReadKey((byte)num, stream); if (key.Field == 0) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } } if (stream.Position != position) { throw new ProtocolBufferException("Read past max limit"); } return(instance); }
public void CopyTo(CodeLock instance) { if (this.pv == null) { instance.pv = null; } else if (instance.pv != null) { this.pv.CopyTo(instance.pv); } else { instance.pv = this.pv.Copy(); } instance.hasCode = this.hasCode; instance.hasGuestCode = this.hasGuestCode; }
public static void SerializeDelta(Stream stream, CodeLock instance, CodeLock previous) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); if (instance.pv != null) { stream.WriteByte(10); memoryStream.SetLength((long)0); CodeLock.Private.SerializeDelta(memoryStream, instance.pv, previous.pv); uint length = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length); stream.Write(memoryStream.GetBuffer(), 0, (int)length); } stream.WriteByte(16); ProtocolParser.WriteBool(stream, instance.hasCode); stream.WriteByte(24); ProtocolParser.WriteBool(stream, instance.hasGuestCode); Pool.FreeMemoryStream(ref memoryStream); }
public static CodeLock Deserialize(Stream stream, CodeLock instance, bool isDelta) { while (true) { int num = stream.ReadByte(); if (num == -1) { break; } if (num == 10) { if (instance.pv != null) { CodeLock.Private.DeserializeLengthDelimited(stream, instance.pv, isDelta); } else { instance.pv = CodeLock.Private.DeserializeLengthDelimited(stream); } } else if (num == 16) { instance.hasCode = ProtocolParser.ReadBool(stream); } else if (num == 24) { instance.hasGuestCode = ProtocolParser.ReadBool(stream); } else { Key key = ProtocolParser.ReadKey((byte)num, stream); if (key.Field == 0) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } } return(instance); }
public void FromProto(Stream stream, bool isDelta = false) { CodeLock.Deserialize(stream, this, isDelta); }
public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false) { CodeLock.DeserializeLength(stream, size, this, isDelta); }
public virtual void WriteToStream(Stream stream) { CodeLock.Serialize(stream, this); }
public byte[] ToProtoBytes() { return(CodeLock.SerializeToBytes(this)); }
public void ToProto(Stream stream) { CodeLock.Serialize(stream, this); }
public static void SerializeLengthDelimited(Stream stream, CodeLock instance) { byte[] bytes = CodeLock.SerializeToBytes(instance); ProtocolParser.WriteUInt32(stream, (uint)bytes.Length); stream.Write(bytes, 0, (int)bytes.Length); }
public void ResetToPool() { CodeLock.ResetToPool(this); }