-
-
-
-
-
-
-
-
|
Copyright © 2004-2019, Schackmann
webmaster@schackmann.net
|
|
singleton
Generates only one single instance at runtime.
using System;
namespace Core
{
/// <summary>
/// The factory.
/// Its purpose is to create the required checking object for the actual dataset.
/// </summary>
public class ASingleton
{
private static ASingleton self;
/// <summary>
/// Constructor.
/// </summary>
private ASingleton()
{
}
/// <summary>
/// This function returns the only instance and creates it if required.
/// </summary>
/// <returns>the instance.</returns>
public static volatile ASingleton GetInstance()
{
/// Test if there is an instance
if( self == null )
lock( typeof( this ))
self = new ASingleton();
return self;
}
}
}
- factory
Returns a specific subclass depending on the parameter.
using System;
namespace Core
{
/// <summary>
/// The factory.
/// Its purpose is to create the required checking object for the actual dataset.
/// </summary>
public class ACheckFactory
{
/// <summary>
/// Constructor.
/// </summary>
public ACheckFactory()
{
}
/// <summary>
/// This function creates and returns the required checker object.
/// </summary>
/// <param name="ds">the dataset to be checked.</param>
/// <returns>the checker that will do the job.</returns>
public ACheckBase GetChecker(AODataSet ds)
{
/// Test if Dataset is Intern or Extern
/// it will create different derivates of ACheckBase
if( ds.isExtern )
return new ACheckExtern(ds);
else
return new ACheckIntern(ds);
}
}
}
adapter
Interfaceadaption
|
|