public void SerializePreferenceManager() { string path = Path; // to keep the same path even if the property is changed JsonPreferenceManager data = ParsePreferences(path); if (data == null) { WritePreferences(CreateData(), path); } else { bool equivalent = false; // compare and write to optimize performance for (int i = 0; i < data.childs.Count && i < childs.Count && equivalent; i++) { equivalent = data.childs[i].IsEquivalentTo(childs[i]); } if (!equivalent) { WritePreferences(CreateData(), path); } else { Console.WriteLine("\tCurrent preferences are the same as the saved ones, no writing required"); } } }
public void DeserializePreferenceManager() { JsonPreferenceManager manager = ParsePreferences(Path); if (manager != null) { childs = manager.childs; } }