Implement singleton pattern for thesauruses.
This commit is contained in:
parent
b421279208
commit
26766dbf81
@ -107,8 +107,8 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
||||
|
||||
public ZaaImporter()
|
||||
{
|
||||
_parameters = new Parameters();
|
||||
_units = new Units();
|
||||
_parameters = Parameters.Default;
|
||||
_units = Units.Default;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user