preference manager's loading system tested and works now.

This commit is contained in:
Harrison Deng 2018-11-19 23:07:57 -06:00
parent 4da7243a60
commit 673cdd0b79

View File

@ -37,11 +37,13 @@ namespace RhythmBullet.Zer01HD.Utilities.Persistence
public void Load()
{
foreach (KeyValuePair<Type, Preferences> prefs in preferenceList)
List<Type> keys = new List<Type>(preferenceList.Keys);
foreach (Type key in keys)
{
if (!LoadSpecific(prefs.Key))
if (!LoadSpecific(key))
{
SaveSpecific(prefs.Key);
SaveSpecific(key);
}
}
}
@ -56,10 +58,10 @@ namespace RhythmBullet.Zer01HD.Utilities.Persistence
private bool LoadSpecific(Type preference)
{
string path = savePath + "/" + preference.Name;
string path = savePath + "/" + preference.Name + ".xml";
if (File.Exists(path))
{
Stream stream = new FileStream(savePath + "/" + preference.Name + ".xml", FileMode.Open);
Stream stream = new FileStream(path, FileMode.Open);
preferenceList[preference] = (Preferences)xmlSerializer.Deserialize(stream);
stream.Close();
return true;