diff --git a/Fushigi.Byml/Serializer/BymlObject.cs b/Fushigi.Byml/Serializer/BymlObject.cs new file mode 100644 index 00000000..e7631ad7 --- /dev/null +++ b/Fushigi.Byml/Serializer/BymlObject.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Fushigi.Byml.Serializer +{ + internal class BymlObject + { + public BymlHashTable HashTable; + + public BymlObject(BymlHashTable bymlHashTable) { + this.HashTable = bymlHashTable; + } + + public void Deserialize() + { + BymlSerialize.Deserialize(this, HashTable); + } + + public void Serialize() + { + var hashTable = BymlSerialize.Serialize(this); + //Merge hash tables. Keep original params intact + foreach (var pair in hashTable.Pairs) + { + //Update or add any hash table params + if (HashTable.ContainsKey(pair.Name)) + HashTable.SetNode(pair.Name, pair.Value); + else + HashTable.AddNode(pair.Id, pair.Value, pair.Name); + } + } + } +}