Bunch of insane work
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public class ViewModelTemplateFactory(IViewModelTemplateDescriptorProvider descriptors,
|
||||
IServiceProvider services) :
|
||||
IViewModelTemplateFactory
|
||||
{
|
||||
public object? Create(object key)
|
||||
{
|
||||
if (descriptors.Get(key)
|
||||
is IViewModelTemplateDescriptor descriptor)
|
||||
{
|
||||
if (services.GetRequiredKeyedService(descriptor.TemplateType,
|
||||
descriptor.Key) is { } template)
|
||||
{
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user