public void should_return_same_instance_of_singletons() { var first = (DownloadMonitoringService)_container.GetRequiredService <IHandle <ApplicationShutdownRequested> >(); var second = _container.GetServices <IHandle <TrackedDownloadsRemovedEvent> >().OfType <ApplicationShutdownRequested>().Single(); first.Should().BeSameAs(second); }
public void should_return_same_instance_via_resolve_and_resolveall() { var first = (DownloadMonitoringService)_container.GetRequiredService <IHandle <TrackedDownloadsRemovedEvent> >(); var second = _container.GetServices <IHandle <TrackedDownloadsRemovedEvent> >().OfType <DownloadMonitoringService>().Single(); first.Should().BeSameAs(second); }
public void should_return_same_instance_of_singletons() { var first = _container.GetServices <IHandle <ApplicationShutdownRequested> >().OfType <Scheduler>().Single(); var second = _container.GetServices <IHandle <ApplicationShutdownRequested> >().OfType <Scheduler>().Single(); first.Should().BeSameAs(second); }
public IEnumerable <T> ResolveAll <T>() { var type = typeof(T); var instances = _serviceProvider.GetServices <T>(); return(instances); }
public static IRemoteStorage BuildS3FileStorage(System.IServiceProvider provider) { var config = provider.GetService <IConfiguration>(); var strat = config.GetValue("AWS:SearchStrategy", "Search"); if (strat.ToLower() == "search") { return(new S3SearchStorage(config, provider.GetService <S3Configuration>())); } else { return(new S3Storage( config, provider.GetService <S3Configuration>(), provider.GetServices <IPatternMatcher>(), provider.GetServices <S3MatchStrategy>())); } }
// this should be removed in a future release internal static IRemoteStorage GetStorage(System.IServiceProvider provider) { var logger = provider.GetService <ILogger <Hosting.DownlinkBuilder> >(); logger?.LogDebug("Running service factory for IRemoteStorage"); var config = provider.GetService <IConfiguration>(); var backend = config.GetValue("Storage", string.Empty).ToLower().Trim(); var providers = provider.GetServices <IRemoteStorage>(); return(providers.GetStorageFor(backend)); }