You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
562 B
24 lines
562 B
namespace Common.StartupHelpers;
|
|
|
|
public class AbstractFactory<T> : IAbstractFactory<T>
|
|
{
|
|
private readonly Func<T> factory;
|
|
|
|
/// <summary>
|
|
/// Constructor for Abstract Factory.
|
|
/// </summary>
|
|
/// <param name="factory">factory function</param>
|
|
public AbstractFactory(Func<T> factory)
|
|
{
|
|
this.factory = factory;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Executes factory function and returns instanciated object.
|
|
/// </summary>
|
|
/// <returns>created object</returns>
|
|
public T Create()
|
|
{
|
|
return factory();
|
|
}
|
|
} |