Add project files.
This commit is contained in:
15
WinGreedWPF/StartupHelpers/ServiceExtensions.cs
Normal file
15
WinGreedWPF/StartupHelpers/ServiceExtensions.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace WinGreedWPF.StartupHelpers;
|
||||
|
||||
public static class ServiceExtensions
|
||||
{
|
||||
public static void AddFormFactory<TForm>(this IServiceCollection services)
|
||||
where TForm : class
|
||||
{
|
||||
services.AddTransient<TForm>();
|
||||
services.AddSingleton<Func<TForm>>(x => () => x.GetService<TForm>()!);
|
||||
services.AddSingleton<IAbstractFactory<TForm>, AbstractFactory<TForm>>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user