16 lines
467 B
C#
16 lines
467 B
C#
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>>();
|
|
}
|
|
}
|