namespace Chernobyl.Creation
{
///
/// An that produces the same instance every time is invoked.
///
public class StaticFactory : Builder, IFactory
{
/// The single instance to return on creation.
public StaticFactory(T instance)
{
Instance = instance;
}
///
/// Performs an implicit conversion from an instance of type to
/// .
///
public static implicit operator StaticFactory(T instance)
{
return new StaticFactory(instance);
}
///
public T Create()
{
ReportCreation(Instance);
return Instance;
}
///
/// The single instance to return on creation.
///
public T Instance { get; }
}
}