protected override void SerializeBody(ITypeWriter typeWriter) { typeWriter.WriteList(TestList); typeWriter.Write(TestBool); typeWriter.Write(TestInt); typeWriter.Write(TestFloat); }
protected override void SerializeRequestBody(ITypeWriter typeWriter) { typeWriter.Write(RoomId); typeWriter.Write(CurrentPlayerCount); typeWriter.Write((byte)State); typeWriter.Write(MaxMatchMakingWeight); }
protected override void SerializeBody(ITypeWriter typeWriter) { typeWriter.Write(RoomId); typeWriter.Write(MaxPlayers); typeWriter.Write(CurrentPlayers); typeWriter.WriteDictionary(RoomProperties, typeWriter.Write); typeWriter.Write((byte)State); }
protected override void SerializeBody(ITypeWriter typeWriter) { typeWriter.Write((byte)ResultCode); typeWriter.Write(Message); if (ResultCode == ResultCode.OK) { SerializeResponseBody(typeWriter); } }
public void Serialize(ITypeWriter typeWriter) { typeWriter.Write((byte)this.ResultCode); typeWriter.Write(this.Message); if (this.ResultCode != ResultCode.OK) { return; } this.SerializeResponseBody(typeWriter); }
protected override void SerializeRequestBody(ITypeWriter typeWriter) { typeWriter.Write(RoomId); typeWriter.Write(Players.Count); foreach (var property in Players) { typeWriter.Write(property.Key); typeWriter.WriteDictionary(property.Value, typeWriter.Write); } }
protected override void SerializeBody(ITypeWriter typeWriter) { lock (_mutex) { typeWriter.Write(IntChanges); typeWriter.Write(NullableIntChanges); typeWriter.Write(ByteChanges); typeWriter.Write(NullableByteChanges); typeWriter.Write(NullableFloatChanges); } }
public void Serialize(ITypeWriter typeWriter) { typeWriter.Write((byte)this.ServerRole); typeWriter.Write(this.Address); typeWriter.Write(Ports.Count); foreach (var port in Ports) { typeWriter.Write(port); } typeWriter.Write(this.PortsString); }
public static void WriteNullable <T>(this ITypeWriter writer, T obj) where T : class, ISerializable { if (obj != null) { writer.Write(true); writer.Write(obj); } else { writer.Write(false); } }
public static void Write(this ITypeWriter writer, Guid?guid) { if (guid.HasValue) { writer.Write((byte)1); writer.Write(guid.Value); } else { writer.Write((byte)0); } }
public static void Write(this ITypeWriter typeWriter, byte?value) { if (value == null) { typeWriter.Write(false); } else { typeWriter.Write(true); typeWriter.Write(value.Value); } }
public static void WriteList(this ITypeWriter bw, IList <string> list) { if (list != null && list.Any()) { bw.Write(list.Count); for (var i = 0; i < list.Count; i++) { bw.Write(list[i]); } } else { bw.Write(0); } }
public static void WriteList <T>(this ITypeWriter bw, ICollection <T> list) where T : ISerializable { if (list != null) { bw.Write(list.Count); foreach (var el in list) { el.Serialize(bw); } } else { bw.Write(0); } }
public static void Write(this ITypeWriter serializer, ConcurrentDictionary <int, ConcurrentDictionary <byte, byte> > dict) { if (dict == null) { dict = new ConcurrentDictionary <int, ConcurrentDictionary <byte, byte> >(); } serializer.Write(dict.Count); foreach (var item in dict) { serializer.Write(item.Key); serializer.Write(item.Value.Count); foreach (var subItem in item.Value) { serializer.Write((byte)subItem.Key); serializer.Write(subItem.Value); } } }
public static void Write(this ITypeWriter typeWriter, HashSet <int> hashSet) { try { if (hashSet == null) { hashSet = new HashSet <int>(); } typeWriter.Write(hashSet.Count()); foreach (var item in hashSet) { typeWriter.Write(item); } } catch (Exception e) { throw new Exception($"Error serializing HashSet<int>: {e}"); } }
protected override void SerializeBody(ITypeWriter typeWriter) { typeWriter.Write(ServerIpAddress); typeWriter.Write(ServerPort); typeWriter.Write(RoomId); typeWriter.Write((byte)Status); typeWriter.Write(CurrentPlayers); typeWriter.Write(MaxPlayers); typeWriter.Write(JoinToExisting); }
/// <summary> /// Please, avoid such structures in code /// </summary> /// <param name="writer"></param> /// <param name="dict"></param> /// <param name="writeKey"></param> /// <typeparam name="TKey"></typeparam> public static void WriteDictionary <TKey>(this ITypeWriter writer, Dictionary <TKey, object> dict, Action <TKey> writeKey) { var dictCount = dict.Count; writer.Write(dictCount); foreach (var entry in dict) { writeKey(entry.Key); WriteObjectValue(writer, entry); } }
protected override void SerializeRequestBody(ITypeWriter typeWriter) { typeWriter.Write(ServerIdentity); typeWriter.Write(Name); typeWriter.Write(Region); typeWriter.Write(PeersCount); typeWriter.Write(HttpPort); typeWriter.Write(HttpsPort); }
public async Task StartVisit(ILabeledTreeNode <TypeContext[]> node) { if (node.Path.Equals(NodePath.RootPath)) { return; } var pathLabel = node.Path.GetNodeLabel(); await _writer.WriteLineAsync($"package {pathLabel} {{"); foreach (var typeContext in node.Data) { WrittenTypes.Add(typeContext.Type); _typeWriter.Write(_writer, typeContext.Type); } }
public static void WriteEntity <T>(this ITypeWriter typeWriter, T entity) where T : EntityBase { try { typeWriter.Write(entity != null); if (entity == null) { return; } entity.Serialize(typeWriter); } catch (Exception e) { throw new Exception($"Error serializing entity <{typeof(T)}>: {e}"); } }
/// <summary> /// Saves the specified value. /// </summary> /// <param name="value">The value.</param> /// <param name="stream">The stream.</param> /// <param name="format">The format.</param> public void Save(object value, Stream stream, IFormat format) { if (value == null) { throw new ArgumentNullException("value"); } ITypeWriter contentWriter = this.GetWriter(value.GetType()); if (contentWriter.BypassFormat) { format = Format.None; } using (IFormatWriter formatWriter = format.CreateWriter(stream)) { contentWriter.Write(formatWriter, value); } }
private static void WriteObjectValue <TKey>(ITypeWriter writer, KeyValuePair <TKey, object> entry) { var value = entry.Value; if (value == null) { value = ""; } writer.Write(SwitchTypeToValue[value.GetType()]); if (!SwitchWrite.ContainsKey(value.GetType())) { throw new Exception($"Type {value.GetType()} is not supported by Write method"); } SwitchWrite[value.GetType()](writer, value); }
public static void Write <T>(this ITypeWriter typeWriter, EntityDictionary <T> list) where T : EntityBase { EntityDictionary <T> list1 = list; try { if (list1 == null) { list1 = new EntityDictionary <T>(); } typeWriter.Write(list1.Count()); foreach (var item in list1) { item.Serialize(typeWriter); } } catch (Exception e) { throw new Exception($"Error serializing EntityDictionary<{typeof(T)}>: {e}"); } }
protected override void SerializeBody(ITypeWriter typeWriter) { typeWriter.WriteList(UpdatedInfoList); typeWriter.Write(ChangeId); }
protected override void SerializeResponseBody(ITypeWriter typeWriter) { typeWriter.Write(CanJoin); }
protected override void SerializeResponseBody(ITypeWriter typeWriter) { typeWriter.Write(BundleUri); }
protected override void SerializeBody(ITypeWriter typeWriter) { typeWriter.Write(Address); typeWriter.Write(Ports); typeWriter.Write((byte)ServerRole); typeWriter.Write(Name); typeWriter.Write(Region); typeWriter.Write(ClientVersion); typeWriter.Write(ActualizedOn); typeWriter.Write(IsApproved); typeWriter.Write(PeerCount); typeWriter.Write(HttpPort); typeWriter.Write(HttpsPort); }
protected override void SerializeRequestBody(ITypeWriter typeWriter) { typeWriter.WriteDictionary(MatchMakingProperties, typeWriter.Write); typeWriter.Write(MatchMakingWeight); }
protected override void SerializeRequestBody(ITypeWriter typeWriter) { typeWriter.Write(RoomId); }
public static void Write(this ITypeWriter writer, DateTime?dateTime) { writer.Write(dateTime?.ToBinary() ?? 0L); }