public static ServiceProvider Initialize(this ServiceProvider provider, Assembly?assembly = null) { provider.ConfigureAwait(false); IEnumerable <Type> serviceTypes = GetServiceTypes(assembly); foreach (Type serviceType in serviceTypes) { _ = provider.GetRequiredService(serviceType); } return(provider); }