public static void Serialize(Stream stream, ServerState instance) { BinaryWriter binaryWriter = new BinaryWriter(stream); if (instance.HasCurrentLoad) { stream.WriteByte(13); binaryWriter.Write(instance.CurrentLoad); } if (instance.HasGameCount) { stream.WriteByte(16); ProtocolParser.WriteUInt32(stream, instance.GameCount); } if (instance.HasPlayerCount) { stream.WriteByte(24); ProtocolParser.WriteUInt32(stream, instance.PlayerCount); } }
public static void Serialize(Stream stream, ServerInfo instance) { BinaryWriter binaryWriter = new BinaryWriter(stream); if (instance.Host == null) { throw new ArgumentNullException("Host", "Required by proto specification."); } stream.WriteByte(10); ProtocolParser.WriteUInt32(stream, instance.Host.GetSerializedSize()); ProcessId.Serialize(stream, instance.Host); if (instance.HasReplace) { stream.WriteByte(16); ProtocolParser.WriteBool(stream, instance.Replace); } if (instance.HasState) { stream.WriteByte(26); ProtocolParser.WriteUInt32(stream, instance.State.GetSerializedSize()); ServerState.Serialize(stream, instance.State); } if (instance.Attribute.get_Count() > 0) { using (List <Attribute> .Enumerator enumerator = instance.Attribute.GetEnumerator()) { while (enumerator.MoveNext()) { Attribute current = enumerator.get_Current(); stream.WriteByte(34); ProtocolParser.WriteUInt32(stream, current.GetSerializedSize()); bnet.protocol.attribute.Attribute.Serialize(stream, current); } } } if (instance.HasProgramId) { stream.WriteByte(45); binaryWriter.Write(instance.ProgramId); } }
public override bool Equals(object obj) { ServerState serverState = obj as ServerState; if (serverState == null) { return(false); } if (this.HasCurrentLoad != serverState.HasCurrentLoad || this.HasCurrentLoad && !this.CurrentLoad.Equals(serverState.CurrentLoad)) { return(false); } if (this.HasGameCount != serverState.HasGameCount || this.HasGameCount && !this.GameCount.Equals(serverState.GameCount)) { return(false); } if (this.HasPlayerCount == serverState.HasPlayerCount && (!this.HasPlayerCount || this.PlayerCount.Equals(serverState.PlayerCount))) { return(true); } return(false); }
public static void Serialize(Stream stream, ServerInfo instance) { BinaryWriter binaryWriter = new BinaryWriter(stream); if (instance.Host == null) { throw new ArgumentNullException("Host", "Required by proto specification."); } stream.WriteByte(10); ProtocolParser.WriteUInt32(stream, instance.Host.GetSerializedSize()); ProcessId.Serialize(stream, instance.Host); if (instance.HasReplace) { stream.WriteByte(16); ProtocolParser.WriteBool(stream, instance.Replace); } if (instance.HasState) { stream.WriteByte(26); ProtocolParser.WriteUInt32(stream, instance.State.GetSerializedSize()); ServerState.Serialize(stream, instance.State); } if (instance.Attribute.Count > 0) { foreach (bnet.protocol.attribute.Attribute attribute in instance.Attribute) { stream.WriteByte(34); ProtocolParser.WriteUInt32(stream, attribute.GetSerializedSize()); bnet.protocol.attribute.Attribute.Serialize(stream, attribute); } } if (instance.HasProgramId) { stream.WriteByte(45); binaryWriter.Write(instance.ProgramId); } }
public void SetState(ServerState val) { this.State = val; }
public static ServerInfo Deserialize(Stream stream, ServerInfo instance, long limit) { BinaryReader binaryReader = new BinaryReader(stream); instance.Replace = false; if (instance.Attribute == null) { instance.Attribute = new List <bnet.protocol.attribute.Attribute>(); } 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 != 16) { if (num != 26) { if (num != 34) { if (num != 45) { 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 = binaryReader.ReadUInt32(); } } else { instance.Attribute.Add(bnet.protocol.attribute.Attribute.DeserializeLengthDelimited(stream)); } } else if (instance.State == null) { instance.State = ServerState.DeserializeLengthDelimited(stream); } else { ServerState.DeserializeLengthDelimited(stream, instance.State); } } else { instance.Replace = ProtocolParser.ReadBool(stream); } } else if (instance.Host == null) { instance.Host = ProcessId.DeserializeLengthDelimited(stream); } else { ProcessId.DeserializeLengthDelimited(stream, instance.Host); } } if (stream.Position == limit) { return(instance); } throw new ProtocolBufferException("Read past max limit"); }
public override bool Equals(object obj) { ServerState serverState = obj as ServerState; return(serverState != null && this.HasCurrentLoad == serverState.HasCurrentLoad && (!this.HasCurrentLoad || this.CurrentLoad.Equals(serverState.CurrentLoad)) && this.HasGameCount == serverState.HasGameCount && (!this.HasGameCount || this.GameCount.Equals(serverState.GameCount)) && this.HasPlayerCount == serverState.HasPlayerCount && (!this.HasPlayerCount || this.PlayerCount.Equals(serverState.PlayerCount))); }
public void Serialize(Stream stream) { ServerState.Serialize(stream, this); }
public static ServerState Deserialize(Stream stream, ServerState instance) { return(ServerState.Deserialize(stream, instance, -1L)); }