using System.Collections.Generic;
namespace RecrownedGTK.Persistence {
///
/// Serializable preferences.
///
public struct PreferencesInfo {
///
/// Array of preferences.
///
public PreferenceInfo[] preferences;
///
/// Sets the serializable preference with a string string value pair dictionary.
///
/// A dictionary of string and string pair.
public void SetPreferences(Dictionary preferences)
{
this.preferences = new PreferenceInfo[preferences.Count];
int pairIndex = 0;
foreach (KeyValuePair item in preferences)
{
this.preferences[pairIndex] = new PreferenceInfo(item.Key, item.Value);
pairIndex++;
}
}
///
/// Return a dictionary containing a string string key value pair.
///
/// Dictionary with a string value and string key representing a preference option.
public Dictionary GetPreferences() {
Dictionary res = new Dictionary();
for (int prefID = 0; prefID < preferences.Length; prefID++) {
res.Add(preferences[prefID].key, preferences[prefID].value);
}
return res;
}
///
/// Serializable preference option.
///
public struct PreferenceInfo {
///
/// The key and value of the option in the preferences.
///
public string key, value;
public PreferenceInfo(string key, string value) {
this.key = key;
this.value = value;
}
}
}
}