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