Even more documentation.

This commit is contained in:
2019-01-14 01:26:46 -06:00
parent 40c7772559
commit b019b7cf10
16 changed files with 368 additions and 46 deletions

View File

@@ -6,12 +6,20 @@ using System.Xml.Serialization;
namespace RecrownedAthenaeum.Persistence
{
/// <summary>
/// Manages a bundle of preferences.
/// </summary>
public class PreferencesManager
{
private readonly Dictionary<Type, object> preferenceList;
string savePath;
XmlSerializer xmlSerializer;
/// <summary>
/// Constructs the preference manager.
/// </summary>
/// <param name="savePath">The path of the directory in which the preferences should be saved.</param>
/// <param name="preferences">The preferences to be serialized and unserialized in XML format.</param>
public PreferencesManager(string savePath, params object[] preferences)
{
this.savePath = savePath;
@@ -29,11 +37,19 @@ namespace RecrownedAthenaeum.Persistence
xmlSerializer = new XmlSerializer(typeof(object), preferenceTypes);
}
/// <summary>
/// Returns the preference by type.
/// </summary>
/// <typeparam name="T">The preference needed.</typeparam>
/// <returns>The preference needed.</returns>
public T GetPreferences<T>()
{
return (T)preferenceList[typeof(T)];
}
/// <summary>
/// Loads preferences.
/// </summary>
public void Load()
{
List<Type> keys = new List<Type>(preferenceList.Keys);
@@ -47,6 +63,9 @@ namespace RecrownedAthenaeum.Persistence
}
}
/// <summary>
/// Saves preferences.
/// </summary>
public void Save()
{
foreach (KeyValuePair<Type, object> prefs in preferenceList)