54 references to TryAddSingleton
Aspire.NATS.Net (2)
AspireNatsClientExtensions.cs (2)
153builder.Services.TryAddSingleton(Factory); 154builder.Services.TryAddSingleton<INatsConnection>(static provider => provider.GetRequiredService<NatsConnection>());
Aspire.StackExchange.Redis (1)
src\Vendoring\OpenTelemetry.Instrumentation.StackExchangeRedis\TracerProviderBuilderExtensions.cs (1)
180services.TryAddSingleton(
BasicWebSite (1)
StartupWithoutEndpointRouting.cs (1)
53services.TryAddSingleton(CreateWeatherForecastService);
Microsoft.AspNetCore.Antiforgery (1)
AntiforgeryServiceCollectionExtensions.cs (1)
39services.TryAddSingleton<ObjectPool<AntiforgerySerializationContext>>(serviceProvider =>
Microsoft.AspNetCore.Components.Endpoints (1)
DependencyInjection\RazorComponentsServiceCollectionExtensions.cs (1)
56services.TryAddSingleton<ServerComponentSerializer>(services => new ServerComponentSerializer(services.GetRequiredService<IDataProtectionProvider>()));
Microsoft.AspNetCore.Components.WebView.Maui (1)
src\BlazorWebView\src\SharedSource\BlazorWebViewServiceCollectionExtensions.cs (1)
45 services.TryAddSingleton(_ => new MauiBlazorMarkerService());
Microsoft.AspNetCore.Components.WebView.WindowsForms (1)
src\BlazorWebView\src\SharedSource\BlazorWebViewServiceCollectionExtensions.cs (1)
49 services.TryAddSingleton(_ => new WindowsFormsBlazorMarkerService());
Microsoft.AspNetCore.Components.WebView.Wpf (1)
src\BlazorWebView\src\SharedSource\BlazorWebViewServiceCollectionExtensions.cs (1)
52 services.TryAddSingleton(_ => new WpfBlazorMarkerService());
Microsoft.AspNetCore.DataProtection (1)
DataProtectionServiceCollectionExtensions.cs (1)
83services.TryAddSingleton<IDataProtectionProvider>(s =>
Microsoft.AspNetCore.Grpc.Swagger (1)
GrpcSwaggerServiceExtensions.cs (1)
37services.TryAddSingleton<IApiDescriptionGroupCollectionProvider>(serviceProvider =>
Microsoft.AspNetCore.Hosting (9)
GenericHost\GenericWebHostBuilder.cs (3)
74services.TryAddSingleton(sp => new DiagnosticListener("Microsoft.AspNetCore")); 75services.TryAddSingleton<DiagnosticSource>(sp => sp.GetRequiredService<DiagnosticListener>()); 76services.TryAddSingleton(sp => new ActivitySource("Microsoft.AspNetCore"));
GenericHost\SlimWebHostBuilder.cs (3)
48services.TryAddSingleton(sp => new DiagnosticListener("Microsoft.AspNetCore")); 49services.TryAddSingleton<DiagnosticSource>(sp => sp.GetRequiredService<DiagnosticListener>()); 50services.TryAddSingleton(sp => new ActivitySource("Microsoft.AspNetCore"));
WebHostBuilder.cs (3)
286services.TryAddSingleton(sp => new DiagnosticListener("Microsoft.AspNetCore")); 287services.TryAddSingleton<DiagnosticSource>(sp => sp.GetRequiredService<DiagnosticListener>()); 288services.TryAddSingleton(sp => new ActivitySource("Microsoft.AspNetCore"));
Microsoft.AspNetCore.Mvc.ApiExplorer (2)
DependencyInjection\EndpointMethodInfoApiExplorerServiceCollectionExtensions.cs (1)
25services.TryAddSingleton<IApiDescriptionGroupCollectionProvider>(sp => new ApiDescriptionGroupCollectionProvider(
DependencyInjection\MvcApiExplorerMvcCoreBuilderExtensions.cs (1)
35services.TryAddSingleton<IApiDescriptionGroupCollectionProvider>(sp => new ApiDescriptionGroupCollectionProvider(
Microsoft.AspNetCore.Mvc.Core (1)
DependencyInjection\MvcCoreServiceCollectionExtensions.cs (1)
215services.TryAddSingleton<IObjectModelValidator>(s =>
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (1)
DependencyInjection\RazorRuntimeCompilationMvcCoreBuilderExtensions.cs (1)
94services.TryAddSingleton(s =>
Microsoft.AspNetCore.Mvc.RazorPages (1)
DependencyInjection\MvcRazorPagesMvcCoreBuilderExtensions.cs (1)
141services.TryAddSingleton<IPageLoader>(s => s.GetRequiredService<PageLoader>());
Microsoft.AspNetCore.Mvc.ViewFeatures (1)
DependencyInjection\MvcViewFeaturesMvcCoreBuilderExtensions.cs (1)
161services.TryAddSingleton<IModelExpressionProvider>(s => s.GetRequiredService<ModelExpressionProvider>());
Microsoft.AspNetCore.OutputCaching (1)
OutputCacheServiceCollectionExtensions.cs (1)
31services.TryAddSingleton<IOutputCacheStore>(sp =>
Microsoft.AspNetCore.Routing (3)
DependencyInjection\RoutingServiceCollectionExtensions.cs (3)
51services.TryAddSingleton<ObjectPool<UriBuildingContext>>(s => 75services.TryAddSingleton<EndpointDataSource>(s => 89services.TryAddSingleton<EndpointMetadataComparer>(services =>
Microsoft.DotNet.Helix.Sdk (2)
ProvisioningProfileProvider.cs (2)
241collection.TryAddSingleton(_ => new HttpClient(new HttpClientHandler { CheckCertificateRevocationList = true })); 242collection.TryAddSingleton<IProvisioningProfileProvider>(serviceProvider =>
Microsoft.Extensions.Compliance.Testing (2)
FakeRedactionServiceCollectionExtensions.cs (2)
29services.TryAddSingleton<IRedactorProvider>(serviceProvider => 55services.TryAddSingleton<IRedactorProvider>(serviceProvider =>
Microsoft.Extensions.Diagnostics.ResourceMonitoring (1)
ResourceMonitorBuilder.cs (1)
21services.TryAddSingleton<IResourceMonitor>(static sp => sp.GetRequiredService<ResourceMonitorService>());
Microsoft.Extensions.Http (2)
DependencyInjection\HttpClientFactoryServiceCollectionExtensions.cs (2)
41services.TryAddSingleton<IHttpClientFactory>(serviceProvider => serviceProvider.GetRequiredService<DefaultHttpClientFactory>()); 42services.TryAddSingleton<IHttpMessageHandlerFactory>(serviceProvider => serviceProvider.GetRequiredService<DefaultHttpClientFactory>());
Microsoft.Extensions.ServiceDiscovery (2)
ServiceDiscoveryServiceCollectionExtensions.cs (2)
64services.TryAddSingleton(_ => TimeProvider.System); 68services.TryAddSingleton(sp => new ServiceEndpointResolver(sp.GetRequiredService<ServiceEndpointWatcherFactory>(), sp.GetRequiredService<TimeProvider>()));
Microsoft.Extensions.WebEncoders (3)
EncoderServiceCollectionExtensions.cs (3)
32services.TryAddSingleton( 34services.TryAddSingleton( 36services.TryAddSingleton(
Microsoft.Maui (10)
Hosting\Dispatching\AppHostBuilderExtensions.cs (2)
14 builder.Services.TryAddSingleton<IDispatcherProvider>(svc => 20 builder.Services.TryAddSingleton<ApplicationDispatcher>((svc) => new ApplicationDispatcher(GetDispatcher(svc, false)));
Hosting\Fonts\FontsMauiAppBuilderExtensions.cs (3)
31 builder.Services.TryAddSingleton<IEmbeddedFontLoader>(svc => new EmbeddedFontLoader(svc)); 32 builder.Services.TryAddSingleton<IFontRegistrar>(svc => new FontRegistrar(svc.GetRequiredService<IEmbeddedFontLoader>(), svc)); 33 builder.Services.TryAddSingleton<IFontManager>(svc => new FontManager(svc.GetRequiredService<IFontRegistrar>(), svc));
Hosting\HandlerMauiAppBuilderExtensions.cs (2)
25 services.TryAddSingleton<IMauiHandlersFactory>(sp => new MauiHandlersFactory(sp.GetRequiredService<IMauiHandlersCollection>())); 26 services.TryAddSingleton<IMauiHandlersCollection>(sp => new HandlerServiceBuilder(sp.GetServices<HandlerRegistration>()));
Hosting\ImageSources\ImageSourcesMauiAppBuilderExtensions.cs (2)
31 builder.Services.TryAddSingleton<IImageSourceServiceProvider>(svcs => new ImageSourceServiceProvider(svcs.GetRequiredService<IImageSourceServiceCollection>(), svcs)); 32 builder.Services.TryAddSingleton<IImageSourceServiceCollection>(svcs => new ImageSourceServiceBuilder(svcs.GetServices<ImageSourceRegistration>()));
Hosting\LifecycleEvents\AppHostBuilderExtensions.cs (1)
27 builder.Services.TryAddSingleton<ILifecycleEventService>(sp => new LifecycleEventService(sp.GetServices<LifecycleEventRegistration>()));
Microsoft.Maui.Controls (2)
Hosting\AppHostBuilderExtensions.cs (1)
57 builder.Services.TryAddSingleton<IApplication>(implementationFactory);
Hosting\Effects\AppHostBuilderExtensions.cs (1)
45 builder.Services.TryAddSingleton(svc => new EffectsFactory(svc.GetServices<EffectsRegistration>()));