2020-02-29 22:15:33 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
namespace RecrownedGTK.Persistence {
|
2020-04-04 22:35:06 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Serializable preferences.
|
|
|
|
/// </summary>
|
2020-02-29 22:15:33 +00:00
|
|
|
public struct PreferencesInfo {
|
2020-04-04 22:35:06 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Array of preferences.
|
|
|
|
/// </summary>
|
2020-02-29 22:15:33 +00:00
|
|
|
public PreferenceInfo[] preferences;
|
2020-04-04 22:35:06 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the serializable preference with a string string value pair dictionary.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="preferences">A dictionary of string and string pair.</param>
|
2020-02-29 22:15:33 +00:00
|
|
|
public void SetPreferences(Dictionary<string, string> preferences)
|
|
|
|
{
|
|
|
|
this.preferences = new PreferenceInfo[preferences.Count];
|
|
|
|
int pairIndex = 0;
|
|
|
|
foreach (KeyValuePair<string, string> item in preferences)
|
|
|
|
{
|
|
|
|
this.preferences[pairIndex] = new PreferenceInfo(item.Key, item.Value);
|
|
|
|
pairIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-04 22:35:06 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Return a dictionary containing a string string key value pair.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>Dictionary with a string value and string key representing a preference option.</returns>
|
2020-02-29 22:15:33 +00:00
|
|
|
public Dictionary<string, string> GetPreferences() {
|
|
|
|
Dictionary<string, string> res = new Dictionary<string, string>();
|
|
|
|
for (int prefID = 0; prefID < preferences.Length; prefID++) {
|
|
|
|
res.Add(preferences[prefID].key, preferences[prefID].value);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2020-04-04 22:35:06 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Serializable preference option.
|
|
|
|
/// </summary>
|
2020-02-29 22:15:33 +00:00
|
|
|
public struct PreferenceInfo {
|
2020-04-04 22:35:06 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The key and value of the option in the preferences.
|
|
|
|
/// </summary>
|
2020-02-29 22:15:33 +00:00
|
|
|
public string key, value;
|
|
|
|
|
|
|
|
public PreferenceInfo(string key, string value) {
|
|
|
|
this.key = key;
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|