-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BymlObject for keeping original parameters intact during serializ…
…ation
- Loading branch information
1 parent
199ffdc
commit 270a301
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} | ||
} |