using Microsoft.Extensions.DependencyInjection;
using MultiTerm.Core.Factories;
using MultiTerm.Core.ViewModel;
namespace MultiTerm.Core.Helpers;
public static class ServiceExtensions
{
///
/// Service Extension to add all implementations of to Dependency Injection.
/// Also adds to Dependency injection, which allows instanciation of during runtime.
///
/// existing services collection
public static void AddTerminalViewModelFactory(this IServiceCollection services)
{
// add all implementations to the services collection
services.AddTransient();
// TODO extend
// add a function to the services collection, which is used by the TerminalViewModelFactory
// to get a list of all registered implementations of ITerminalViewModel
services.AddSingleton>>(x => () => x.GetService>()!);
// add the factory itself to the services collection
services.AddSingleton();
}
}