Files
dan_clark@outlook.com 2ac0e3ed26 project
2022-03-23 15:44:32 +00:00

30 lines
801 B
C#

namespace TheXamlGuy.TaskbarGroup.Core
{
public class ServiceFactory : IServiceFactory
{
private readonly Func<Type, object> factory;
private readonly Func<Type, object[], object> factoryWithParameters;
public ServiceFactory(Func<Type, object> factory, Func<Type, object[], object> factoryWithParameters)
{
this.factory = factory;
this.factoryWithParameters = factoryWithParameters;
}
public T Create<T>(params object[] parameters)
{
return (T)factoryWithParameters(typeof(T), parameters);
}
public T Create<T>(Type type)
{
return (T)factory(type);
}
public T Create<T>()
{
return (T)factory(typeof(T));
}
}
}