public static void Serialize(Stream stream, SubscribeRequest instance) { BinaryWriter binaryWriter = new BinaryWriter(stream); if (instance.HasAgentId) { stream.WriteByte(10); ProtocolParser.WriteUInt32(stream, instance.AgentId.GetSerializedSize()); bnet.protocol.EntityId.Serialize(stream, instance.AgentId); } if (instance.EntityId == null) { throw new ArgumentNullException("EntityId", "Required by proto specification."); } stream.WriteByte(18); ProtocolParser.WriteUInt32(stream, instance.EntityId.GetSerializedSize()); bnet.protocol.EntityId.Serialize(stream, instance.EntityId); stream.WriteByte(24); ProtocolParser.WriteUInt64(stream, instance.ObjectId); if (instance.ProgramId.Count > 0) { foreach (uint programId in instance.ProgramId) { stream.WriteByte(37); binaryWriter.Write(programId); } } }
public override bool Equals(object obj) { SubscribeRequest subscribeRequest = obj as SubscribeRequest; if (subscribeRequest == null) { return(false); } if (this.HasAgentId != subscribeRequest.HasAgentId || this.HasAgentId && !this.AgentId.Equals(subscribeRequest.AgentId)) { return(false); } if (!this.EntityId.Equals(subscribeRequest.EntityId)) { return(false); } if (!this.ObjectId.Equals(subscribeRequest.ObjectId)) { return(false); } if (this.ProgramId.Count != subscribeRequest.ProgramId.Count) { return(false); } for (int i = 0; i < this.ProgramId.Count; i++) { if (!this.ProgramId[i].Equals(subscribeRequest.ProgramId[i])) { return(false); } } return(true); }
public static SubscribeRequest DeserializeLengthDelimited(Stream stream, SubscribeRequest instance) { long position = (long)ProtocolParser.ReadUInt32(stream); position += stream.Position; return(SubscribeRequest.Deserialize(stream, instance, position)); }
public static SubscribeRequest DeserializeLengthDelimited(Stream stream) { SubscribeRequest subscribeRequest = new SubscribeRequest(); SubscribeRequest.DeserializeLengthDelimited(stream, subscribeRequest); return(subscribeRequest); }
public static SubscribeRequest DeserializeLengthDelimited(Stream stream, SubscribeRequest instance) { long num = (long)((ulong)ProtocolParser.ReadUInt32(stream)); num += stream.get_Position(); return(SubscribeRequest.Deserialize(stream, instance, num)); }
public static void Serialize(Stream stream, SubscribeRequest instance) { BinaryWriter binaryWriter = new BinaryWriter(stream); if (instance.HasAgentId) { stream.WriteByte(10); ProtocolParser.WriteUInt32(stream, instance.AgentId.GetSerializedSize()); EntityId.Serialize(stream, instance.AgentId); } if (instance.EntityId == null) { throw new ArgumentNullException("EntityId", "Required by proto specification."); } stream.WriteByte(18); ProtocolParser.WriteUInt32(stream, instance.EntityId.GetSerializedSize()); EntityId.Serialize(stream, instance.EntityId); stream.WriteByte(24); ProtocolParser.WriteUInt64(stream, instance.ObjectId); if (instance.ProgramId.get_Count() > 0) { using (List <uint> .Enumerator enumerator = instance.ProgramId.GetEnumerator()) { while (enumerator.MoveNext()) { uint current = enumerator.get_Current(); stream.WriteByte(37); binaryWriter.Write(current); } } } }
public void Serialize(Stream stream) { SubscribeRequest.Serialize(stream, this); }
public static SubscribeRequest Deserialize(Stream stream, SubscribeRequest instance, long limit) { BinaryReader binaryReader = new BinaryReader(stream); if (instance.ProgramId == null) { instance.ProgramId = new List <uint>(); } while (limit < 0L || stream.Position < limit) { int num = stream.ReadByte(); if (num == -1) { if (limit >= 0L) { throw new EndOfStreamException(); } return(instance); } else if (num != 10) { if (num != 18) { if (num != 24) { if (num != 37) { Key key = ProtocolParser.ReadKey((byte)num, stream); uint field = key.Field; if (field == 0u) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } else { instance.ProgramId.Add(binaryReader.ReadUInt32()); } } else { instance.ObjectId = ProtocolParser.ReadUInt64(stream); } } else if (instance.EntityId == null) { instance.EntityId = EntityId.DeserializeLengthDelimited(stream); } else { EntityId.DeserializeLengthDelimited(stream, instance.EntityId); } } else if (instance.AgentId == null) { instance.AgentId = EntityId.DeserializeLengthDelimited(stream); } else { EntityId.DeserializeLengthDelimited(stream, instance.AgentId); } } if (stream.Position == limit) { return(instance); } throw new ProtocolBufferException("Read past max limit"); }
public static SubscribeRequest Deserialize(Stream stream, SubscribeRequest instance) { return(SubscribeRequest.Deserialize(stream, instance, -1L)); }