public void Serialize(IPofWriter writer) { writer.WriteBoolean(0, keysPolymorphic); writer.WriteBoolean(1, valuesPolymorphic); writer.WriteS32(2, items.Count); var context = writer.Context; var serializer = new PofSerializer(context); using (var elementStream = new MemoryStream()) { using (var elementStreamWriter = new BinaryWriter(elementStream, Encoding.UTF8, true)) { var keySerializationFlags = keysPolymorphic ? SerializationFlags.None : SerializationFlags.Typeless; var valueSerializationFlags = valuesPolymorphic ? SerializationFlags.None : SerializationFlags.Typeless; foreach (var kvp in items) { serializer.Serialize(elementStreamWriter, kvp.Key, keySerializationFlags); serializer.Serialize(elementStreamWriter, kvp.Value, valueSerializationFlags); } } writer.WriteBytes(3, elementStream.ToArray()); } }
public void Serialize(IPofWriter writer) { writer.WriteBoolean(0, isPolymorphic); writer.WriteS32(1, elements.Length); var context = writer.Context; var serializer = new PofSerializer(context); using (var elementStream = new MemoryStream()) { using (var elementStreamWriter = new BinaryWriter(elementStream, Encoding.UTF8, true)) { var serializationFlags = isPolymorphic ? SerializationFlags.None : SerializationFlags.Typeless; foreach (var element in elements) { serializer.Serialize(elementStreamWriter, element, serializationFlags); } } writer.WriteBytes(2, elementStream.ToArray()); } }