コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: ContainerFixture.cs プロジェクト: whoshoe/Readarr
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public IEnumerable <T> ResolveAll <T>()
        {
            var type      = typeof(T);
            var instances = _serviceProvider.GetServices <T>();

            return(instances);
        }
コード例 #5
0
        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>()));
            }
        }
コード例 #6
0
        // 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));
        }