Implement singleton pattern for thesauruses.

This commit is contained in:
Daniel Kraus 2015-07-15 06:58:05 +02:00
parent b421279208
commit 26766dbf81
3 changed files with 38 additions and 2 deletions

View File

@ -107,8 +107,8 @@ namespace zaaReloaded2.Importer.ZaaImporter
public ZaaImporter()
{
_parameters = new Parameters();
_units = new Units();
_parameters = Parameters.Default;
_units = Units.Default;
}
#endregion

View File

@ -32,6 +32,24 @@ namespace zaaReloaded2.Thesaurus
/// </summary>
public class Parameters : ThesaurusBase
{
#region Singleton
private static readonly Parameters _default = new Parameters();
/// <summary>
/// Gets the default singleton instance of the Parameters
/// thesaurus.
/// </summary>
/// <remarks>
/// http://csharpindepth.com/Articles/General/Singleton.aspx#cctor
/// </remarks>
public static Parameters Default { get { return _default; } }
static Parameters() { }
private Parameters() { }
#endregion
#region Public methods
/// <summary>
@ -100,5 +118,6 @@ namespace zaaReloaded2.Thesaurus
}
#endregion
}
}

View File

@ -30,6 +30,23 @@ namespace zaaReloaded2.Thesaurus
/// </summary>
public class Units : ThesaurusBase
{
#region Singleton
private static readonly Units _default = new Units();
/// <summary>
/// Gets the default singleton instance of the Units thesaurus.
/// </summary>
/// <remarks>
/// http://csharpindepth.com/Articles/General/Singleton.aspx#cctor
/// </remarks>
public static Units Default { get { return _default; } }
static Units() { }
private Units() { }
#endregion
#region Public methods
/// <summary>