Implement unique IDs for settings.

This commit is contained in:
Daniel Kraus 2015-08-02 07:19:12 +02:00
parent 286ddb1641
commit 9fd0907310
2 changed files with 22 additions and 0 deletions

View File

@ -47,6 +47,12 @@ namespace zaaReloaded2.Controller
/// </summary> /// </summary>
public IList<ElementBase> Elements { get; private set; } public IList<ElementBase> Elements { get; private set; }
/// <summary>
/// Gets the unique ID of this Settings object. The unique
/// ID is not included in deep-copying (cloning).
/// </summary>
public Guid Uid { get; private set; }
#endregion #endregion
#region Constructors #region Constructors
@ -54,6 +60,7 @@ namespace zaaReloaded2.Controller
public Settings() public Settings()
{ {
Elements = new List<ElementBase>(); Elements = new List<ElementBase>();
Uid = Guid.NewGuid();
} }
public Settings(string name) public Settings(string name)

View File

@ -76,6 +76,21 @@ namespace zaaReloaded2.Controller
#endregion #endregion
#region Public methods
/// <summary>
/// Looks up a Settings object contained in this repository
/// by unique ID.
/// </summary>
/// <param name="uid">GUID to look for.</param>
/// <returns>Settings object with this GUID, or null if the
/// GUID was not found.</returns>
public Settings FindByGuid(Guid uid)
{
return SettingsList.FirstOrDefault(s => s.Uid == uid);
}
#endregion
#region Private methods #region Private methods
/// <summary> /// <summary>