67 references to TryAddSingleton
Microsoft.AspNetCore.Authentication (1)
AuthenticationServiceCollectionExtensions.cs (1)
26services.TryAddSingleton(TimeProvider.System);
Microsoft.AspNetCore.Components.Endpoints.Tests (3)
EndpointHtmlRendererTest.cs (3)
664collection.TryAddSingleton(HtmlEncoder.Default); 665collection.TryAddSingleton<ILoggerFactory>(NullLoggerFactory.Instance); 667collection.TryAddSingleton(_dataprotectorProvider);
Microsoft.AspNetCore.Components.WebView.Maui (1)
src\BlazorWebView\src\SharedSource\BlazorWebViewServiceCollectionExtensions.cs (1)
43 services.TryAddSingleton(new BlazorWebViewDeveloperTools { Enabled = false });
Microsoft.AspNetCore.Components.WebView.WindowsForms (1)
src\BlazorWebView\src\SharedSource\BlazorWebViewServiceCollectionExtensions.cs (1)
43 services.TryAddSingleton(new BlazorWebViewDeveloperTools { Enabled = false });
Microsoft.AspNetCore.Components.WebView.Wpf (1)
src\BlazorWebView\src\SharedSource\BlazorWebViewServiceCollectionExtensions.cs (1)
43 services.TryAddSingleton(new BlazorWebViewDeveloperTools { Enabled = false });
Microsoft.AspNetCore.Diagnostics.Middleware (3)
src\Shared\Debugger\DebuggerExtensions.cs (3)
30services.TryAddSingleton<IDebuggerState>(DebuggerState.System); 44services.TryAddSingleton<IDebuggerState>(DebuggerState.Attached); 58services.TryAddSingleton<IDebuggerState>(DebuggerState.Detached);
Microsoft.AspNetCore.Hosting (3)
GenericHost\GenericWebHostBuilder.cs (1)
77services.TryAddSingleton(DistributedContextPropagator.Current);
GenericHost\SlimWebHostBuilder.cs (1)
51services.TryAddSingleton(DistributedContextPropagator.Current);
WebHostBuilder.cs (1)
289services.TryAddSingleton(DistributedContextPropagator.Current);
Microsoft.AspNetCore.Hosting.Tests (14)
StartupManagerTests.cs (14)
154services.Services.TryAddSingleton(new ServiceBefore { Message = "Configure container" }); 155services.Services.TryAddSingleton(new ServiceAfter { Message = "Configure container" }); 167services.TryAddSingleton(new ServiceBefore { Message = "Configure services" }); 168services.TryAddSingleton(new ServiceAfter { Message = "Configure services" }); 173services.Services.TryAddSingleton(new ServiceBefore { Message = "Configure container" }); 174services.Services.TryAddSingleton(new ServiceAfter { Message = "Configure container" }); 199services.Services.TryAddSingleton(new ServiceBefore { Message = $"ConfigureContainerFilter Before {AdditionalData}" }); 210services.Services.TryAddSingleton(new ServiceAfter { Message = $"ConfigureContainerFilter After {AdditionalData}" }); 220services.TryAddSingleton(new ServiceBefore { Message = "Configure services" }); 221services.TryAddSingleton(new ServiceAfter { Message = "Configure services" }); 248services.TryAddSingleton(new ServiceBefore { Message = $"StartupServicesFilter Before {AdditionalData}" }); 259services.TryAddSingleton(new ServiceAfter { Message = $"StartupServicesFilter After {AdditionalData}" }); 269services.TryAddSingleton(new ServiceBefore { Message = "Configure services" }); 270services.TryAddSingleton(new ServiceAfter { Message = "Configure services" });
Microsoft.AspNetCore.HttpLogging (2)
HttpLoggingServicesExtensions.cs (2)
24services.TryAddSingleton(ObjectPool.ObjectPool.Create<HttpLoggingInterceptorContext>()); 25services.TryAddSingleton(TimeProvider.System);
Microsoft.AspNetCore.Mvc.Core (3)
DependencyInjection\MvcCoreServiceCollectionExtensions.cs (3)
53services.TryAddSingleton(partManager); 232services.TryAddSingleton(ArrayPool<byte>.Shared); 233services.TryAddSingleton(ArrayPool<char>.Shared);
Microsoft.AspNetCore.Mvc.FunctionalTests (1)
Infrastructure\MvcWebApplicationBuilderExtensions.cs (1)
29services.TryAddSingleton(new TestCulture
Microsoft.AspNetCore.Mvc.ViewFeatures (1)
DependencyInjection\MvcViewFeaturesMvcCoreBuilderExtensions.cs (1)
208services.TryAddSingleton(ArrayPool<ViewBufferValue>.Shared);
Microsoft.AspNetCore.SignalR.Core (1)
SignalRDependencyInjectionExtensions.cs (1)
35services.TryAddSingleton(new SignalRServerActivitySource());
Microsoft.AspNetCore.Tests (1)
WebApplicationTests.cs (1)
1818Assert.Throws<InvalidOperationException>(() => builder.Services.TryAddSingleton(new Service()));
Microsoft.DotNet.Build.Tasks.Feed (2)
src\GenerateBuildManifest.cs (1)
114collection.TryAddSingleton(Log);
src\PushToBuildStorage.cs (1)
101collection.TryAddSingleton(Log);
Microsoft.DotNet.Build.Tasks.Feed.Tests (7)
PushToBuildStorageTests.cs (7)
90collection.TryAddSingleton(signingInformationModelFactoryMock.Object); 91collection.TryAddSingleton(blobArtifactModelFactoryMock.Object); 92collection.TryAddSingleton(packageArtifactModelFactoryMock.Object); 93collection.TryAddSingleton(buildModelFactoryMock.Object); 94collection.TryAddSingleton(fileSystemMock.Object); 95collection.TryAddSingleton(nupkgInfoFactoryMock.Object); 96collection.TryAddSingleton(packageArchiveReaderFactoryMock.Object);
Microsoft.DotNet.Helix.Sdk (5)
CreateXHarnessAndroidWorkItems.cs (1)
50collection.TryAddSingleton(Log);
CreateXHarnessAppleWorkItems.cs (1)
69collection.TryAddSingleton(Log);
FindDotNetCliPackage.cs (2)
63collection.TryAddSingleton(_httpMessageHandler); 64collection.TryAddSingleton(Log);
InstallDotNetTool.cs (1)
85collection.TryAddSingleton(Log);
Microsoft.Extensions.Caching.Hybrid (3)
HybridCacheServiceExtensions.cs (3)
36services.TryAddSingleton(TimeProvider.System); 39services.TryAddSingleton<IHybridCacheSerializer<string>>(InbuiltTypeSerializer.Instance); 40services.TryAddSingleton<IHybridCacheSerializer<byte[]>>(InbuiltTypeSerializer.Instance);
Microsoft.Extensions.Http (2)
DependencyInjection\HttpClientFactoryServiceCollectionExtensions.cs (2)
60services.TryAddSingleton(new HttpClientMappingRegistry()); 63services.TryAddSingleton(new DefaultHttpClientConfigurationTracker());
Microsoft.Extensions.Http.Diagnostics (3)
src\Shared\Debugger\DebuggerExtensions.cs (3)
30services.TryAddSingleton<IDebuggerState>(DebuggerState.System); 44services.TryAddSingleton<IDebuggerState>(DebuggerState.Attached); 58services.TryAddSingleton<IDebuggerState>(DebuggerState.Detached);
Microsoft.Extensions.Http.Resilience.Tests (1)
Resilience\HttpClientBuilderExtensionsTests.BySelector.cs (1)
114_builder.Services.TryAddSingleton(provider.Object);
Microsoft.Extensions.Logging.EventSource (1)
EventSourceLoggerFactoryExtensions.cs (1)
43builder.Services.TryAddSingleton(LoggingEventSource.Instance);
Microsoft.Extensions.Resilience.Tests (1)
Resilience\ResilienceServiceCollectionExtensionsTests.cs (1)
28_services.TryAddSingleton(_summarizer.Object);
Microsoft.ML.AutoML (3)
AutoMLExperiment\AutoMLExperiment.cs (3)
69_serviceCollection.TryAddSingleton(_settings); 70_serviceCollection.TryAddSingleton(((IChannelProvider)_context).Start(nameof(AutoMLExperiment))); 71_serviceCollection.TryAddSingleton<IMLContextManager>(new DefaultMLContextManager(_context, $"{nameof(AutoMLExperiment)}-ChildContext"));
Shared (3)
Debugger\DebuggerExtensions.cs (3)
30services.TryAddSingleton<IDebuggerState>(DebuggerState.System); 44services.TryAddSingleton<IDebuggerState>(DebuggerState.Attached); 58services.TryAddSingleton<IDebuggerState>(DebuggerState.Detached);