95 references to AddSingleton
Aspire.Azure.AI.OpenAI (1)
src\Components\Common\AzureComponent.cs (1)
86builder.Services.AddSingleton<TClient>(static _ => null!);
Aspire.Azure.Data.Tables (1)
src\Components\Common\AzureComponent.cs (1)
86builder.Services.AddSingleton<TClient>(static _ => null!);
Aspire.Azure.Messaging.EventHubs (1)
src\Components\Common\AzureComponent.cs (1)
86builder.Services.AddSingleton<TClient>(static _ => null!);
Aspire.Azure.Messaging.ServiceBus (1)
src\Components\Common\AzureComponent.cs (1)
86builder.Services.AddSingleton<TClient>(static _ => null!);
Aspire.Azure.Messaging.WebPubSub (1)
src\Components\Common\AzureComponent.cs (1)
86builder.Services.AddSingleton<TClient>(static _ => null!);
Aspire.Azure.Search.Documents (1)
src\Components\Common\AzureComponent.cs (1)
86builder.Services.AddSingleton<TClient>(static _ => null!);
Aspire.Azure.Security.KeyVault (1)
src\Components\Common\AzureComponent.cs (1)
86builder.Services.AddSingleton<TClient>(static _ => null!);
Aspire.Azure.Storage.Blobs (1)
src\Components\Common\AzureComponent.cs (1)
86builder.Services.AddSingleton<TClient>(static _ => null!);
Aspire.Azure.Storage.Queues (1)
src\Components\Common\AzureComponent.cs (1)
86builder.Services.AddSingleton<TClient>(static _ => null!);
Aspire.Confluent.Kafka (4)
AspireKafkaConsumerExtensions.cs (2)
116builder.Services.AddSingleton<ConsumerConnectionFactory<TKey, TValue>>(sp => CreateConsumerConnectionFactory<TKey, TValue>(sp, configureBuilder, settings)); 117builder.Services.AddSingleton<IConsumer<TKey, TValue>>(sp => sp.GetRequiredService<ConsumerConnectionFactory<TKey, TValue>>().Create());
AspireKafkaProducerExtensions.cs (2)
116builder.Services.AddSingleton<ProducerConnectionFactory<TKey, TValue>>(sp => CreateProducerConnectionFactory<TKey, TValue>(sp, configureBuilder, settings)); 117builder.Services.AddSingleton<IProducer<TKey, TValue>>(sp => sp.GetRequiredService<ProducerConnectionFactory<TKey, TValue>>().Create());
Aspire.Elastic.Clients.Elasticsearch (1)
AspireElasticClientsElasticsearchExtensions.cs (1)
91builder.Services.AddSingleton<ElasticsearchClient>(CreateElasticsearchClient);
Aspire.Hosting (1)
DistributedApplicationBuilder.cs (1)
346_innerBuilder.Services.AddSingleton<IConfigureOptions<HealthCheckPublisherOptions>>(sp =>
Aspire.Microsoft.Azure.Cosmos (1)
AspireMicrosoftAzureCosmosExtensions.cs (1)
116builder.Services.AddSingleton(_ => ConfigureDb());
Aspire.Milvus.Client (1)
AspireMilvusExtensions.cs (1)
83builder.Services.AddSingleton(ConfigureMilvus);
Aspire.MongoDB.Driver (2)
AspireMongoDBDriverExtensions.cs (2)
113.AddSingleton<IMongoClient>(sp => sp.CreateMongoClient(connectionName, mongoDbSettings, configureClientSettings)); 141builder.Services.AddSingleton<IMongoDatabase>(provider =>
Aspire.NATS.Net (1)
AspireNatsClientExtensions.cs (1)
143builder.Services.AddSingleton<INatsJSContext>(static provider =>
Aspire.OpenAI (1)
AspireOpenAIExtensions.cs (1)
104builder.Services.AddSingleton(ConfigureOpenAI);
Aspire.Qdrant.Client (1)
AspireQdrantExtensions.cs (1)
78builder.Services.AddSingleton(ConfigureQdrant);
Aspire.RabbitMQ.Client (1)
AspireRabbitMQExtensions.cs (1)
114builder.Services.AddSingleton<IConnectionFactory>(CreateConnectionFactory);
Aspire.StackExchange.Redis (1)
AspireRedisExtensions.cs (1)
102builder.Services.AddSingleton<IConnectionMultiplexer>(sp => CreateConnection(sp, connectionName, DefaultConfigSectionName, optionsName));
CustomEncryptorSample (1)
CustomBuilderExtensions.cs (1)
18builder.Services.AddSingleton<IConfigureOptions<KeyManagementOptions>>(serviceProvider =>
Microsoft.AspNetCore.Components.Endpoints.Tests (3)
EndpointHtmlRendererTest.cs (2)
1675services.AddSingleton(sp => sp.GetRequiredService<ComponentStatePersistenceManager>().State); 1680services.AddSingleton<PersistentComponentState>(sp => sp.GetRequiredService<ComponentStatePersistenceManager>().State);
RazorComponentResultTest.cs (1)
467.AddSingleton<PersistentComponentState>(sp => sp.GetRequiredService<ComponentStatePersistenceManager>().State)
Microsoft.AspNetCore.Components.Web.Tests (1)
Forms\EditFormTest.cs (1)
24services.AddSingleton(services => services.GetRequiredService<ComponentStatePersistenceManager>().State);
Microsoft.AspNetCore.Components.WebAssembly (2)
Hosting\WebAssemblyHostBuilder.cs (2)
305Services.AddSingleton<RootComponentTypeCache>(_ => _rootComponentCache ?? new()); 307Services.AddSingleton<PersistentComponentState>(sp => sp.GetRequiredService<ComponentStatePersistenceManager>().State);
Microsoft.AspNetCore.DataProtection (6)
DataProtectionBuilderExtensions.cs (6)
88builder.Services.AddSingleton<IConfigureOptions<KeyManagementOptions>>(services => 114builder.Services.AddSingleton<IConfigureOptions<KeyManagementOptions>>(services => 173builder.Services.AddSingleton<IConfigureOptions<KeyManagementOptions>>(services => 197builder.Services.AddSingleton<IConfigureOptions<KeyManagementOptions>>(services => 220builder.Services.AddSingleton<IConfigureOptions<KeyManagementOptions>>(services => 255builder.Services.AddSingleton<IConfigureOptions<KeyManagementOptions>>(services =>
Microsoft.AspNetCore.DataProtection.EntityFrameworkCore (1)
EntityFrameworkCoreDataProtectionExtensions.cs (1)
27builder.Services.AddSingleton<IConfigureOptions<KeyManagementOptions>>(services =>
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (2)
Latency\AddServerTimingHeaderMiddlewareTests.cs (1)
30.AddSingleton<ILatencyContext>(_ => fakeLatencyContextController)
Logging\AcceptanceTests.cs (1)
119x.AddSingleton<TimeProvider>(s => s.GetRequiredService<FakeTimeProvider>());
Microsoft.AspNetCore.Hosting (7)
Internal\WebHost.cs (3)
66_applicationServiceCollection.AddSingleton<IHostApplicationLifetime>(services 69_applicationServiceCollection.AddSingleton<AspNetCore.Hosting.IApplicationLifetime>(services 71_applicationServiceCollection.AddSingleton<Extensions.Hosting.IApplicationLifetime>(services
WebHostBuilder.cs (2)
283services.AddSingleton<IConfiguration>(_ => configuration); 340services.AddSingleton<IStartup>(_ =>
WebHostBuilderExtensions.cs (2)
47services.AddSingleton<IStartup>(sp => 76services.AddSingleton<IStartup>(sp =>
Microsoft.AspNetCore.Hosting.Tests (5)
WebHostBuilderTests.cs (2)
437services.AddSingleton(sp => service); 968services.AddSingleton(sp =>
WebHostTests.cs (3)
504services.AddSingleton<IHostedService>(_ => new DelegateHostedService(started, stopping, disposing)); 594services.AddSingleton<IHostedService>(_ => new DelegateHostedService(started, stopping, disposing)); 647services.AddSingleton<IHostedService>(_ => new DelegateHostedService(started, stopping, disposing));
Microsoft.AspNetCore.Identity.FunctionalTests (2)
MapIdentityApiTests.cs (2)
636services.AddSingleton<IDisposable>(_ => dbConnection2); 1291builder.Services.AddSingleton(_ => dbConnection);
Microsoft.AspNetCore.InternalTesting (2)
AssemblyTestLog.cs (2)
176builder.Services.AddSingleton<ILoggerProvider>(_ => serilogLoggerProvider); 205builder.Services.AddSingleton<ILoggerProvider>(_ => serilogLoggerProvider);
Microsoft.AspNetCore.Mvc.IntegrationTests (2)
ModelBindingTestHelper.cs (2)
175serviceCollection.AddSingleton(services => 183serviceCollection.AddSingleton<IModelMetadataProvider>(services =>
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (2)
PageRemoteAttributeTest.cs (1)
192serviceCollection.AddSingleton<IInlineConstraintResolver>(
RemoteAttributeTest.cs (1)
493serviceCollection.AddSingleton<IInlineConstraintResolver>(
Microsoft.AspNetCore.Routing.Tests (1)
EndpointRoutingMiddlewareTest.cs (1)
406services.AddSingleton<DiagnosticListener>(s => new DiagnosticListener("Test"));
Microsoft.AspNetCore.Server.HttpSys (3)
WebHostBuilderHttpSysExtensions.cs (3)
32services.AddSingleton<IServer>(services => services.GetRequiredService<MessagePump>()); 35services.AddSingleton<IServerDelegationFeature>(services => services.GetRequiredService<MessagePump>()); 38services.AddSingleton<IServerIntegratedAuth>(services =>
Microsoft.AspNetCore.Server.IIS (1)
WebHostBuilderIISExtensions.cs (1)
42services.AddSingleton<IServerIntegratedAuth>(_ => new ServerIntegratedAuth()
Microsoft.AspNetCore.Server.IISIntegration (1)
WebHostBuilderIISExtensions.cs (1)
86services.AddSingleton<IServerIntegratedAuth>(_ => new ServerIntegratedAuth()
Microsoft.AspNetCore.SpaServices.Extensions (1)
StaticFiles\SpaStaticFilesExtensions.cs (1)
27services.AddSingleton<ISpaStaticFileProvider>(serviceProvider =>
Microsoft.AspNetCore.TestHost.Tests (1)
TestServerTests.cs (1)
32services.AddSingleton<IServer>(serviceProvider => new TestServer(serviceProvider));
Microsoft.Extensions.AI (2)
ChatCompletion\ChatClientBuilderServiceCollectionExtensions.cs (1)
36_ = serviceCollection.AddSingleton(builder.Build);
Embeddings\EmbeddingGeneratorBuilderServiceCollectionExtensions.cs (1)
42_ = serviceCollection.AddSingleton(builder.Build);
Microsoft.Extensions.DependencyInjection.AutoActivation (1)
AutoActivationExtensions.cs (1)
142.AddSingleton<TService>(implementationFactory)
Microsoft.Extensions.Diagnostics.Probes (1)
TcpEndpointProbesExtensions.cs (1)
49_ = services.AddSingleton<IHostedService>(provider =>
Microsoft.Extensions.Hosting (3)
HostBuilder.cs (3)
306services.AddSingleton(_ => appConfiguration); 308services.AddSingleton(s => (IApplicationLifetime)s.GetRequiredService<IHostApplicationLifetime>()); 314services.AddSingleton<IHost>(_ =>
Microsoft.Extensions.Http.Diagnostics.PerformanceTests (8)
HttpClientFactory.cs (8)
22.AddSingleton(_ => NoRemoteCallHandler.Create(fileName)) 46.AddSingleton(_ => NoRemoteCallHandler.Create(fileName)) 69.AddSingleton(_ => NoRemoteCallHandler.Create(fileName)) 96.AddSingleton(_ => NoRemoteCallNotSeekableHandler.Create(fileName)) 119.AddSingleton(_ => NoRemoteCallNotSeekableHandler.Create(fileName)) 142.AddSingleton(_ => NoRemoteCallNotSeekableHandler.Create(fileName)) 163.AddSingleton(_ => NoRemoteCallHandler.Create(fileName)) 173.AddSingleton(_ => NoRemoteCallNotSeekableHandler.Create(fileName))
Microsoft.Extensions.Http.Diagnostics.Tests (1)
Logging\AcceptanceTests.cs (1)
35.AddSingleton<IHttpClientLogEnricher>(static _ => null!)
Microsoft.Extensions.Http.Polly (4)
DependencyInjection\PollyServiceCollectionExtensions.cs (4)
103services.AddSingleton(serviceProvider => 112services.AddSingleton<IConcurrentPolicyRegistry<string>>(serviceProvider => serviceProvider.GetRequiredService<PolicyRegistry>()); 113services.AddSingleton<IPolicyRegistry<string>>(serviceProvider => serviceProvider.GetRequiredService<PolicyRegistry>()); 114services.AddSingleton<IReadOnlyPolicyRegistry<string>>(serviceProvider => serviceProvider.GetRequiredService<PolicyRegistry>());
Microsoft.Extensions.Logging.TraceSource (2)
TraceSourceFactoryExtensions.cs (2)
141builder.Services.AddSingleton<ILoggerProvider>(_ => new TraceSourceLoggerProvider(sourceSwitch)); 162builder.Services.AddSingleton<ILoggerProvider>(_ => new TraceSourceLoggerProvider(sourceSwitch, listener));
Microsoft.Extensions.ML (1)
ServiceCollectionExtensions.cs (1)
54services.AddSingleton(implementationFactory));
Microsoft.Extensions.ObjectPool.DependencyInjection (1)
ObjectPoolServiceCollectionExtensions.cs (1)
111.AddSingleton<ObjectPool<TService>>(provider =>
Microsoft.Extensions.Telemetry.Tests (1)
Logging\ExtendedLoggerFactoryTests.cs (1)
533var factory = Utils.CreateLoggerFactory(builder => builder.Services.AddSingleton(_ => provider.Object));
Microsoft.ML.AutoML (2)
API\AutoMLExperimentExtension.cs (1)
312experiment.ServiceCollection.AddSingleton<ITrialResultManager>(serviceProvider =>
AutoMLExperiment\AutoMLExperiment.cs (1)
139_serviceCollection.AddSingleton<IMonitor>(factory);