Start to port main gut of the foundation

This commit is contained in:
Daniel Clark
2022-12-05 17:47:16 +00:00
parent 82a83456f4
commit 3b09265a30
44 changed files with 1075 additions and 1 deletions
@@ -0,0 +1,25 @@
using System.Reflection;
namespace Toolkit.Foundation
{
internal class ServiceFactoryDescriptor
{
private readonly IServiceFactory serviceFactory;
public ServiceFactoryDescriptor(IServiceFactory serviceFactory)
{
this.serviceFactory = serviceFactory;
}
public object? Create(Type type)
{
MethodInfo? methodInfo = typeof(ServiceFactoryDescriptor).GetMethod(nameof(Create), BindingFlags.NonPublic | BindingFlags.Instance);
return methodInfo?.MakeGenericMethod(type).Invoke(this, new object[] { type });
}
private T Create<T>(Type type)
{
return serviceFactory.Create<T>(type);
}
}
}