/// <inheritdoc/> public override void PreSerialize(ref AssetPartCollection <TAssetPartDesign, TAssetPart> obj, ArchiveMode mode, SerializationStream stream) { if (mode == ArchiveMode.Deserialize) { // TODO: Peek the SortedList size if (obj == null) { obj = new AssetPartCollection <TAssetPartDesign, TAssetPart>(); } else { obj.Clear(); } } }
/// <inheritdoc/> public override void Serialize(ref AssetPartCollection <TAssetPartDesign, TAssetPart> obj, ArchiveMode mode, SerializationStream stream) { if (mode == ArchiveMode.Deserialize) { // Should be null if it was var count = stream.ReadInt32(); for (var i = 0; i < count; ++i) { var value = default(TAssetPartDesign); valueSerializer.Serialize(ref value, mode, stream); var key = value.Part.Id; obj.Add(key, value); } } else if (mode == ArchiveMode.Serialize) { stream.Write(obj.Count); foreach (var item in obj) { valueSerializer.Serialize(item.Value, stream); } } }