This commit is contained in:
dan_clark@outlook.com
2022-03-23 15:44:32 +00:00
commit 2ac0e3ed26
129 changed files with 4197 additions and 0 deletions
@@ -0,0 +1,30 @@
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));
}
}
}