Initialization rework
This commit is contained in:
@@ -8,17 +8,6 @@ namespace Toolkit.Foundation
|
||||
{
|
||||
serviceCollection.AddSingleton<IServiceFactory>(provider => new ServiceFactory(provider.GetService, (instanceType, parameters) => ActivatorUtilities.CreateInstance(provider, instanceType, parameters!)));
|
||||
|
||||
serviceCollection
|
||||
.AddSingleton<IInitialization, Initialization>(provider => new Initialization(() =>
|
||||
{
|
||||
return serviceCollection.Where(x => x.ServiceType.GetInterfaces()
|
||||
.Contains(typeof(IInitializer)) || x.ServiceType == typeof(IInitializer))
|
||||
.GroupBy(x => x.ServiceType)
|
||||
.Select(x => x.First())
|
||||
.SelectMany(x => provider.GetServices(x.ServiceType)
|
||||
.Select(x => (IInitializer?)x)).ToList();
|
||||
}));
|
||||
|
||||
return serviceCollection;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user