restructure project for part 2
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.UI.Windows;
|
||||
|
||||
public class TemplateFactory(IEnumerable<IContentTemplateDescriptor> descriptors,
|
||||
IServiceProvider provider) :
|
||||
ITemplateFactory
|
||||
{
|
||||
public object? Create(object key)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.Key == key) is IContentTemplateDescriptor descriptor)
|
||||
{
|
||||
if (provider.GetRequiredKeyedService(descriptor.TemplateType, descriptor.Key) is { } template)
|
||||
{
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user