30 instantiations of ServiceDescriptor
Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL (1)
src\Components\Common\EntityFrameworkUtils.cs (1)
75var dbContextOptionsDescriptor = new ServiceDescriptor(
Aspire.Microsoft.EntityFrameworkCore.Cosmos (1)
src\Components\Common\EntityFrameworkUtils.cs (1)
75var dbContextOptionsDescriptor = new ServiceDescriptor(
Aspire.Microsoft.EntityFrameworkCore.SqlServer (1)
src\Components\Common\EntityFrameworkUtils.cs (1)
75var dbContextOptionsDescriptor = new ServiceDescriptor(
Aspire.MongoDB.EntityFrameworkCore (1)
src\Components\Common\EntityFrameworkUtils.cs (1)
75var dbContextOptionsDescriptor = new ServiceDescriptor(
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL (1)
src\Components\Common\EntityFrameworkUtils.cs (1)
75var dbContextOptionsDescriptor = new ServiceDescriptor(
Aspire.Oracle.EntityFrameworkCore (1)
src\Components\Common\EntityFrameworkUtils.cs (1)
75var dbContextOptionsDescriptor = new ServiceDescriptor(
Aspire.Pomelo.EntityFrameworkCore.MySql (1)
src\Components\Common\EntityFrameworkUtils.cs (1)
75var dbContextOptionsDescriptor = new ServiceDescriptor(
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (1)
DatabaseDeveloperPageExceptionFilterServiceExtensions.cs (1)
30services.TryAddEnumerable(new ServiceDescriptor(typeof(IDeveloperPageExceptionFilter), typeof(DatabaseDeveloperPageExceptionFilter), ServiceLifetime.Singleton));
Microsoft.Extensions.AI (10)
ChatCompletion\ChatClientBuilderServiceCollectionExtensions.cs (2)
49serviceCollection.Add(new ServiceDescriptor(typeof(IChatClient), builder.Build, lifetime)); 93serviceCollection.Add(new ServiceDescriptor(typeof(IChatClient), serviceKey, factory: (services, serviceKey) => builder.Build(services), lifetime));
Embeddings\EmbeddingGeneratorBuilderServiceCollectionExtensions.cs (4)
55serviceCollection.Add(new ServiceDescriptor(typeof(IEmbeddingGenerator<TInput, TEmbedding>), builder.Build, lifetime)); 56serviceCollection.Add(new ServiceDescriptor(typeof(IEmbeddingGenerator), 107serviceCollection.Add(new ServiceDescriptor(typeof(IEmbeddingGenerator<TInput, TEmbedding>), serviceKey, factory: (services, serviceKey) => builder.Build(services), lifetime)); 108serviceCollection.Add(new ServiceDescriptor(typeof(IEmbeddingGenerator), serviceKey,
Image\ImageGeneratorBuilderServiceCollectionExtensions.cs (2)
45serviceCollection.Add(new ServiceDescriptor(typeof(IImageGenerator), builder.Build, lifetime)); 82serviceCollection.Add(new ServiceDescriptor(typeof(IImageGenerator), serviceKey, factory: (services, serviceKey) => builder.Build(services), lifetime));
SpeechToText\SpeechToTextClientBuilderServiceCollectionExtensions.cs (2)
43serviceCollection.Add(new ServiceDescriptor(typeof(ISpeechToTextClient), builder.Build, lifetime)); 78serviceCollection.Add(new ServiceDescriptor(typeof(ISpeechToTextClient), serviceKey, factory: (services, serviceKey) => builder.Build(services), lifetime));
Microsoft.Extensions.DependencyInjection.Abstractions (12)
ServiceCollectionServiceExtensions.cs (3)
570var serviceDescriptor = new ServiceDescriptor(serviceType, implementationInstance); 606var descriptor = new ServiceDescriptor(serviceType, implementationType, lifetime); 617var descriptor = new ServiceDescriptor(serviceType, implementationFactory, lifetime);
ServiceCollectionServiceExtensions.Keyed.cs (3)
619var serviceDescriptor = new ServiceDescriptor(serviceType, serviceKey, implementationInstance); 658var descriptor = new ServiceDescriptor(serviceType, serviceKey, implementationType, lifetime); 670var descriptor = new ServiceDescriptor(serviceType, serviceKey, implementationFactory, lifetime);
ServiceDescriptor.cs (6)
936return new ServiceDescriptor(serviceType, implementationInstance); 956return new ServiceDescriptor(serviceType, serviceKey, implementationInstance); 986return new ServiceDescriptor(serviceType, implementationType, lifetime); 1005return new ServiceDescriptor(serviceType, serviceKey, implementationType, lifetime); 1019return new ServiceDescriptor(serviceType, implementationFactory, lifetime); 1034return new ServiceDescriptor(serviceType, serviceKey, implementationFactory, lifetime);
829 references to ServiceDescriptor
aspire (7)
Program.cs (7)
398builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IAgentEnvironmentScanner, VsCodeAgentEnvironmentScanner>()); 399builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IAgentEnvironmentScanner, CopilotCliAgentEnvironmentScanner>()); 400builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IAgentEnvironmentScanner, OpenCodeAgentEnvironmentScanner>()); 401builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IAgentEnvironmentScanner, ClaudeCodeAgentEnvironmentScanner>()); 402builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IAgentEnvironmentScanner, DeprecatedMcpCommandScanner>()); 407builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ITemplateFactory, DotNetTemplateFactory>()); 408builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ITemplateFactory, CliTemplateFactory>());
Aspire.Azure.AI.Inference (2)
AspireAzureAIInferenceExtensions.cs (2)
83/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 339/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Azure.AI.OpenAI (2)
AspireAzureOpenAIExtensions.cs (1)
62/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
AspireConfigurableOpenAIExtensions.cs (1)
53/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Azure.Data.Tables (1)
AspireTablesExtensions.cs (1)
65/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Azure.Messaging.EventHubs (5)
AspireEventHubsExtensions.cs (5)
48/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 94/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 140/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 187/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 234/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Azure.Messaging.ServiceBus (1)
AspireServiceBusExtensions.cs (1)
50/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Azure.Messaging.WebPubSub (1)
AspireWebPubSubExtensions.cs (1)
50/// <param name="serviceKey">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service, as well as the hub name is hub name is not set in the settings</param>
Aspire.Azure.Npgsql (1)
AspireAzureNpgsqlExtensions.cs (1)
51/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL (5)
src\Components\Common\EntityFrameworkUtils.cs (5)
43public static ServiceDescriptor CheckDbContextRegistered<TContext>(this IHostApplicationBuilder builder, [CallerMemberName] string memberName = "") 50var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 66var oldDbContextOptionsDescriptor = builder.CheckDbContextRegistered<TContext>(memberName); 75var dbContextOptionsDescriptor = new ServiceDescriptor( 106var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (5)
EnrichNpgsqlTests.cs (5)
127var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 166var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 172var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 213var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 266var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.Azure.Search.Documents (1)
AspireAzureSearchExtensions.cs (1)
50/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Azure.Security.KeyVault (3)
AspireKeyVaultExtensions.cs (3)
52/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection information from the ConnectionStrings configuration section.</param> 96/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection information from the ConnectionStrings configuration section.</param> 140/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection information from the ConnectionStrings configuration section.</param>
Aspire.Azure.Storage.Blobs (2)
AspireBlobStorageExtensions.cs (2)
68/// The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve 145/// The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve
Aspire.Azure.Storage.Files.DataLake (1)
AspireDataLakeExtensions.cs (1)
54/// The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey" /> of the service and also to retrieve
Aspire.Azure.Storage.Queues (3)
AspireQueueStorageExtensions.cs (3)
76/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 98/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 153/// The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve
Aspire.Cli.Tests (6)
Commands\ExportCommandTests.cs (2)
276services.Replace(ServiceDescriptor.Singleton<IHttpClientFactory>(new MockHttpClientFactory(handler))); 751services.Replace(ServiceDescriptor.Singleton<IHttpClientFactory>(new MockHttpClientFactory(handler)));
Commands\SecretCommandTests.cs (1)
77services.Replace(ServiceDescriptor.Singleton<IAppHostProjectFactory>(
Commands\TelemetryTestHelper.cs (1)
124services.Replace(ServiceDescriptor.Singleton<IHttpClientFactory>(new MockHttpClientFactory(handler)));
Utils\CliTestHelper.cs (2)
107services.TryAddEnumerable(ServiceDescriptor.Singleton<ITemplateFactory, DotNetTemplateFactory>()); 108services.TryAddEnumerable(ServiceDescriptor.Singleton<ITemplateFactory, CliTemplateFactory>());
Aspire.Confluent.Kafka (2)
AspireKafkaConsumerExtensions.cs (1)
100/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
AspireKafkaProducerExtensions.cs (1)
100/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Dashboard (2)
DashboardWebApplication.cs (2)
299builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IOutgoingPeerResolver, ResourceOutgoingPeerResolver>()); 300builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IOutgoingPeerResolver, BrowserLinkOutgoingPeerResolver>());
Aspire.Dashboard.Tests (1)
Integration\StartupTests.cs (1)
1052ServiceDescriptor.Transient<IStartupFilter, HostAndProtocolLoggerFilter>(_ => filter));
Aspire.Hosting (12)
Dashboard\DashboardServiceHost.cs (1)
110builder.Services.Add(ServiceDescriptor.Singleton(typeof(ILogger<>), typeof(Logger<>)));
DistributedApplicationBuilder.cs (8)
382_innerBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<DcpOptions>, ConfigureDefaultDcpOptions>()); 383_innerBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IValidateOptions<DcpOptions>, ValidateDcpOptions>()); 461_innerBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IValidateOptions<TransportOptions>, TransportOptionsValidator>()); 466_innerBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<DashboardOptions>, ConfigureDefaultDashboardOptions>()); 467_innerBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IValidateOptions<DashboardOptions>, ValidateDashboardOptions>()); 477_innerBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<CodespacesOptions>, ConfigureCodespacesOptions>()); 480_innerBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<DevcontainersOptions>, ConfigureDevcontainersOptions>()); 481_innerBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<SshRemoteOptions>, ConfigureSshRemoteOptions>());
Lifecycle\EventingSubscriberServiceCollectionExtensions.cs (1)
31services.TryAddEnumerable(ServiceDescriptor.Singleton<IDistributedApplicationEventingSubscriber, T>());
Lifecycle\LifecycleHookServiceCollectionExtensions.cs (2)
33services.TryAddEnumerable(ServiceDescriptor.Singleton<IDistributedApplicationLifecycleHook, T>()); 57services.TryAddEnumerable(ServiceDescriptor.Singleton<IDistributedApplicationLifecycleHook, T>(implementationFactory));
Aspire.Hosting.Testing (5)
DistributedApplicationFactory.cs (5)
558var hostDescriptor = applicationBuilder.Services.Single(s => s.ServiceType == typeof(IHost) && s.ServiceKey is null); 562var interceptedDescriptor = hostDescriptor switch 564{ ImplementationFactory: { } factory } => ServiceDescriptor.KeyedSingleton<IHost>(this, (sp, _) => (IHost)factory(sp)), 565{ ImplementationInstance: { } instance } => ServiceDescriptor.KeyedSingleton<IHost>(this, (IHost)instance), 566{ ImplementationType: { } type } => ServiceDescriptor.KeyedSingleton(typeof(IHost), this, type),
Aspire.Hosting.Tests (1)
WithHttpCommandTests.cs (1)
30var httpClientFactoryServiceDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(IHttpClientFactory));
Aspire.Microsoft.Azure.Cosmos (3)
AspireMicrosoftAzureCosmosExtensions.cs (3)
83/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 109/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 170/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Microsoft.Data.SqlClient (1)
AspireSqlServerSqlClientExtensions.cs (1)
39/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Microsoft.EntityFrameworkCore.Cosmos (5)
src\Components\Common\EntityFrameworkUtils.cs (5)
43public static ServiceDescriptor CheckDbContextRegistered<TContext>(this IHostApplicationBuilder builder, [CallerMemberName] string memberName = "") 50var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 66var oldDbContextOptionsDescriptor = builder.CheckDbContextRegistered<TContext>(memberName); 75var dbContextOptionsDescriptor = new ServiceDescriptor( 106var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Microsoft.EntityFrameworkCore.Cosmos.Tests (1)
EnrichCosmosDbTests.cs (1)
112var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.Microsoft.EntityFrameworkCore.SqlServer (5)
src\Components\Common\EntityFrameworkUtils.cs (5)
43public static ServiceDescriptor CheckDbContextRegistered<TContext>(this IHostApplicationBuilder builder, [CallerMemberName] string memberName = "") 50var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 66var oldDbContextOptionsDescriptor = builder.CheckDbContextRegistered<TContext>(memberName); 75var dbContextOptionsDescriptor = new ServiceDescriptor( 106var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Microsoft.EntityFrameworkCore.SqlServer.Tests (5)
EnrichSqlServerTests.cs (5)
122var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 160var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 166var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 203var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 253var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.MongoDB.Driver (1)
AspireMongoDBDriverExtensions.cs (1)
45/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.MongoDB.EntityFrameworkCore (5)
src\Components\Common\EntityFrameworkUtils.cs (5)
43public static ServiceDescriptor CheckDbContextRegistered<TContext>(this IHostApplicationBuilder builder, [CallerMemberName] string memberName = "") 50var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 66var oldDbContextOptionsDescriptor = builder.CheckDbContextRegistered<TContext>(memberName); 75var dbContextOptionsDescriptor = new ServiceDescriptor( 106var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.MongoDB.EntityFrameworkCore.Tests (1)
EnrichMongoDbTests.cs (1)
81var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.MySqlConnector (1)
AspireMySqlConnectorExtensions.cs (1)
40/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.NATS.Net (1)
AspireNatsClientExtensions.cs (1)
104/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Npgsql (1)
AspirePostgreSqlNpgsqlExtensions.cs (1)
40/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL (5)
src\Components\Common\EntityFrameworkUtils.cs (5)
43public static ServiceDescriptor CheckDbContextRegistered<TContext>(this IHostApplicationBuilder builder, [CallerMemberName] string memberName = "") 50var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 66var oldDbContextOptionsDescriptor = builder.CheckDbContextRegistered<TContext>(memberName); 75var dbContextOptionsDescriptor = new ServiceDescriptor( 106var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (5)
EnrichNpgsqlTests.cs (5)
129var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 168var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 174var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 212var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 265var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.OpenAI (1)
AspireOpenAIExtensions.cs (1)
41/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.Oracle.EntityFrameworkCore (5)
src\Components\Common\EntityFrameworkUtils.cs (5)
43public static ServiceDescriptor CheckDbContextRegistered<TContext>(this IHostApplicationBuilder builder, [CallerMemberName] string memberName = "") 50var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 66var oldDbContextOptionsDescriptor = builder.CheckDbContextRegistered<TContext>(memberName); 75var dbContextOptionsDescriptor = new ServiceDescriptor( 106var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Oracle.EntityFrameworkCore.Tests (5)
EnrichOracleDatabaseTests.cs (5)
122var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 160var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 166var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 203var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 253var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.Pomelo.EntityFrameworkCore.MySql (5)
src\Components\Common\EntityFrameworkUtils.cs (5)
43public static ServiceDescriptor CheckDbContextRegistered<TContext>(this IHostApplicationBuilder builder, [CallerMemberName] string memberName = "") 50var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 66var oldDbContextOptionsDescriptor = builder.CheckDbContextRegistered<TContext>(memberName); 75var dbContextOptionsDescriptor = new ServiceDescriptor( 106var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Pomelo.EntityFrameworkCore.MySql.Tests (5)
EnrichMySqlTests.cs (5)
138var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 176var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 182var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 219var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 269var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.RabbitMQ.Client (1)
src\Components\Aspire.RabbitMQ.Client\AspireRabbitMQExtensions.cs (1)
50/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.StackExchange.Redis (2)
AspireRedisExtensions.cs (2)
62/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 78/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
Aspire.StackExchange.Redis.DistributedCaching (2)
AspireRedisDistributedCacheExtensions.cs (2)
52/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param> 133/// <param name="name">The name which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param>
Aspire.StackExchange.Redis.OutputCaching (1)
AspireRedisOutputCacheExtensions.cs (1)
51/// <param name="name">The name of the component, which is used as the <see cref="ServiceDescriptor.ServiceKey"/> of the service and also to retrieve the connection string from the ConnectionStrings configuration section.</param>
AspireWithMaui.MauiServiceDefaults (1)
Extensions.cs (1)
62ServiceDescriptor.Transient<IMauiInitializeService, OpenTelemetryInitializer>(_ => new OpenTelemetryInitializer()));
IntegrationTestsWebsite (1)
Startup.cs (1)
25services.TryAddEnumerable(ServiceDescriptor.Singleton<IServiceMethodProvider<DynamicService>, DynamicServiceModelProvider>());
Microsoft.AspNetCore (7)
BootstrapHostBuilder.cs (4)
24foreach (var descriptor in _builder.Services) 85public ServiceDescriptor RunDefaultCallbacks() 104ServiceDescriptor? genericWebHostServiceDescriptor = null; 108var descriptor = _builder.Services[i];
WebApplicationBuilder.cs (3)
30private readonly ServiceDescriptor _genericWebHostServiceDescriptor; 204private ServiceDescriptor InitializeHosting(BootstrapHostBuilder bootstrapHostBuilder) 208var genericWebHostServiceDescriptor = bootstrapHostBuilder.RunDefaultCallbacks();
Microsoft.AspNetCore.Antiforgery (1)
AntiforgeryServiceCollectionExtensions.cs (1)
28ServiceDescriptor.Transient<IConfigureOptions<AntiforgeryOptions>, AntiforgeryOptionsSetup>());
Microsoft.AspNetCore.AsyncState.Tests (1)
AsyncStateHttpContextExtensionsTests.cs (1)
28var serviceDescriptor = services.First(x => x.ServiceType == typeof(IHttpContextAccessor));
Microsoft.AspNetCore.Authentication (2)
AuthenticationBuilder.cs (2)
52Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, PostConfigureAuthenticationSchemeOptions<TOptions>>()); 97Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, EnsureSignInScheme<TOptions>>());
Microsoft.AspNetCore.Authentication.BearerToken (2)
BearerTokenExtensions.cs (2)
68builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<JsonOptions>, BearerTokenConfigureJsonOptions>()); 69builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<BearerTokenOptions>, BearerTokenConfigureOptions>());
Microsoft.AspNetCore.Authentication.Cookies (1)
CookieExtensions.cs (1)
79builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
Microsoft.AspNetCore.Authentication.JwtBearer (2)
JwtBearerExtensions.cs (2)
77builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<JwtBearerOptions>, JwtBearerConfigureOptions>()); 78builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerPostConfigureOptions>());
Microsoft.AspNetCore.Authentication.Negotiate (2)
NegotiateExtensions.cs (2)
71builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<NegotiateOptions>, PostConfigureNegotiateOptions>()); 72builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IStartupFilter>(new NegotiateOptionsValidationStartupFilter(authenticationScheme)));
Microsoft.AspNetCore.Authentication.OAuth (1)
OAuthExtensions.cs (1)
62builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, OAuthPostConfigureOptions<TOptions, THandler>>());
Microsoft.AspNetCore.Authentication.OpenIdConnect (2)
OpenIdConnectExtensions.cs (2)
71builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<OpenIdConnectOptions>, OpenIdConnectConfigureOptions>()); 72builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>());
Microsoft.AspNetCore.Authentication.Twitter (1)
TwitterExtensions.cs (1)
69builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>());
Microsoft.AspNetCore.Authentication.WsFederation (1)
WsFederationExtensions.cs (1)
53builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<WsFederationOptions>, WsFederationPostConfigureOptions>());
Microsoft.AspNetCore.Authorization (7)
AuthorizationServiceCollectionExtensions.cs (7)
32services.TryAdd(ServiceDescriptor.Singleton<AuthorizationMetrics, AuthorizationMetrics>()); 33services.TryAdd(ServiceDescriptor.Transient<IAuthorizationService, DefaultAuthorizationServiceImpl>()); 34services.TryAdd(ServiceDescriptor.Transient<IAuthorizationPolicyProvider, DefaultAuthorizationPolicyProvider>()); 35services.TryAdd(ServiceDescriptor.Transient<IAuthorizationHandlerProvider, DefaultAuthorizationHandlerProvider>()); 36services.TryAdd(ServiceDescriptor.Transient<IAuthorizationEvaluator, DefaultAuthorizationEvaluator>()); 37services.TryAdd(ServiceDescriptor.Transient<IAuthorizationHandlerContextFactory, DefaultAuthorizationHandlerContextFactory>()); 38services.TryAddEnumerable(ServiceDescriptor.Transient<IAuthorizationHandler, PassThroughAuthorizationHandler>());
Microsoft.AspNetCore.Components (7)
CascadingValueServiceCollectionExtensions.cs (3)
68ServiceDescriptor.Scoped<ICascadingValueSupplier, CascadingValueSource<TValue>>( 86ServiceDescriptor.Scoped<ICascadingValueSupplier, CascadingValueSource<TValue>>( 107ServiceDescriptor.Scoped<ICascadingValueSupplier, CascadingValueSource<TValue>>(sourceFactory));
PersistentState\PersistentStateProviderServiceCollectionExtensions.cs (1)
21services.TryAddEnumerable(ServiceDescriptor.Scoped<ICascadingValueSupplier, PersistentStateValueProvider>());
RegisterPersistentComponentStateServiceCollectionExtensions.cs (1)
38services.TryAddEnumerable(ServiceDescriptor.Singleton<IPersistentServiceRegistration>(new PersistentServiceRegistration<TService>(componentRenderMode)));
RegisterRenderingMetricsServiceCollectionExtensions.cs (1)
48foreach (var service in services)
SupplyParameterFromQueryProviderServiceCollectionExtensions.cs (1)
22services.TryAddEnumerable(ServiceDescriptor.Scoped<ICascadingValueSupplier, SupplyParameterFromQueryValueProvider>());
Microsoft.AspNetCore.Components.Endpoints (1)
DependencyInjection\RazorComponentsServiceCollectionExtensions.cs (1)
68ServiceDescriptor.Singleton<IPostConfigureOptions<RazorComponentsServiceOptions>, DefaultRazorComponentsServiceOptionsConfiguration>());
Microsoft.AspNetCore.Components.Endpoints.Tests (4)
HotReloadServiceTests.cs (1)
200services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(RenderModeEndpointProvider), type));
RazorComponentEndpointDataSourceTest.cs (1)
217services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(RenderModeEndpointProvider), type));
RazorComponentsServiceCollectionExtensionsTest.cs (2)
28foreach (var service in services) 57foreach (var service in services)
Microsoft.AspNetCore.Components.Server (5)
DependencyInjection\ComponentServiceCollectionExtensions.cs (4)
61services.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, BlazorPackHubProtocol>()); 103services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CircuitOptions>, DefaultHybridCache>()); 114services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<CircuitOptions>, CircuitOptionsJSInteropDetailedErrorsConfiguration>()); 115services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<CircuitOptions>, CircuitOptionsJavaScriptInitializersConfiguration>());
DependencyInjection\ServerRazorComponentsBuilderExtensions.cs (1)
38builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<RenderModeEndpointProvider, CircuitEndpointProvider>());
Microsoft.AspNetCore.Components.Web (1)
Forms\Mapping\SupplyParameterFromFormServiceCollectionExtensions.cs (1)
21serviceCollection.TryAddEnumerable(ServiceDescriptor.Scoped<ICascadingValueSupplier, SupplyParameterFromFormValueProvider>(services =>
Microsoft.AspNetCore.Components.WebAssembly.Server (2)
WebAssemblyRazorComponentsBuilderExtensions.cs (2)
27builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<RenderModeEndpointProvider, WebAssemblyEndpointProvider>()); 43builder.Services.TryAddEnumerable(ServiceDescriptor.Scoped<IHostEnvironmentAuthenticationStateProvider, AuthenticationStateSerializer>());
Microsoft.AspNetCore.Components.WebView.Test (2)
ComponentsWebViewServiceCollectionExtensionsTests.cs (2)
41var persistenceManagerDescriptor = services.FirstOrDefault(s => s.ServiceType == typeof(ComponentStatePersistenceManager)); 42var persistentStateDescriptor = services.FirstOrDefault(s => s.ServiceType == typeof(PersistentComponentState));
Microsoft.AspNetCore.Cors (2)
CorsServiceCollectionExtensions.cs (2)
25services.TryAdd(ServiceDescriptor.Transient<ICorsService, CorsService>()); 26services.TryAdd(ServiceDescriptor.Transient<ICorsPolicyProvider, DefaultCorsPolicyProvider>());
Microsoft.AspNetCore.DataProtection (5)
DataProtectionBuilderExtensions.cs (1)
521builder.Services.Replace(ServiceDescriptor.Singleton<IDataProtectionProvider, EphemeralDataProtectionProvider>());
DataProtectionServiceCollectionExtensions.cs (4)
69ServiceDescriptor.Singleton<IConfigureOptions<KeyManagementOptions>, KeyManagementOptionsSetup>()); 71ServiceDescriptor.Singleton<IPostConfigureOptions<KeyManagementOptions>, KeyManagementOptionsPostSetup>()); 73ServiceDescriptor.Transient<IConfigureOptions<DataProtectionOptions>, DataProtectionOptionsSetup>()); 77services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, DataProtectionHostedService>());
Microsoft.AspNetCore.DataProtection.Tests (4)
HostingTests.cs (3)
34.Replace(ServiceDescriptor.Singleton(mockKeyRing.Object)) 63.Replace(ServiceDescriptor.Singleton(mockKeyRing.Object)) 92.Replace(ServiceDescriptor.Singleton(mockKeyRing.Object))
ServiceCollectionTests.cs (1)
59foreach (var descriptor in serviceCollection)
Microsoft.AspNetCore.Diagnostics.Middleware (2)
Latency\RequestLatencyTelemetryServiceCollectionExtensions.cs (1)
73services.TryAddEnumerable(ServiceDescriptor.Singleton<IStartupFilter, CapturePipelineEntryStartupFilter>());
Logging\HttpLoggingServiceCollectionExtensions.cs (1)
40services.TryAddEnumerable(ServiceDescriptor.Singleton<IHttpLoggingInterceptor, HttpLoggingRedactionInterceptor>());
Microsoft.AspNetCore.Grpc.JsonTranscoding (2)
GrpcJsonTranscodingServiceExtensions.cs (2)
29builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(IServiceMethodProvider<>), typeof(JsonTranscodingServiceMethodProvider<>))); 30builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<GrpcJsonTranscodingOptions>, GrpcJsonTranscodingOptionsSetup>());
Microsoft.AspNetCore.Grpc.Swagger (2)
GrpcSwaggerServiceExtensions.cs (2)
33services.TryAddEnumerable(ServiceDescriptor.Transient<IApiDescriptionProvider, GrpcJsonTranscodingDescriptionProvider>()); 48services.Replace(ServiceDescriptor.Transient<ISerializerDataContractResolver>(s =>
Microsoft.AspNetCore.Hosting (5)
Internal\ServiceCollectionExtensions.cs (1)
13foreach (var service in serviceCollection)
WebHostBuilder.cs (3)
357services.Replace(ServiceDescriptor.Singleton(typeof(DiagnosticListener), listener!)); 358services.Replace(ServiceDescriptor.Singleton(typeof(DiagnosticSource), listener!)); 361services.Replace(ServiceDescriptor.Singleton(typeof(ActivitySource), activitySource!));
WebHostBuilderExtensions.cs (1)
205services.Replace(ServiceDescriptor.Singleton<IServiceProviderFactory<IServiceCollection>>(new DefaultServiceProviderFactory(options)));
Microsoft.AspNetCore.Hosting.Tests (4)
WebHostBuilderTests.cs (3)
1657internal ServiceDescriptor ServiceADescriptor { get; set; } 1694var heDescriptor = services.LastOrDefault(s => s.ServiceType == typeof(IHostingEnvironment)); 1698var wheDescriptor = services.LastOrDefault(s => s.ServiceType == typeof(IWebHostEnvironment));
WebHostTests.AsyncDisposable.cs (1)
18services.Add(ServiceDescriptor.Singleton<IServiceProviderFactory<IServiceCollection>>(providerFactory)
Microsoft.AspNetCore.Http.Connections (1)
ConnectionsDependencyInjectionExtensions.cs (1)
25services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<ConnectionOptions>, ConnectionOptionsSetup>());
Microsoft.AspNetCore.Http.Extensions (2)
ProblemDetailsServiceCollectionExtensions.cs (2)
42services.TryAddEnumerable(ServiceDescriptor.Singleton<IProblemDetailsWriter, DefaultProblemDetailsWriter>()); 44services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<JsonOptions>, ProblemDetailsJsonOptionsSetup>());
Microsoft.AspNetCore.Http.Tests (1)
HttpServiceCollectionExtensionsTests.cs (1)
20var descriptor = services[0];
Microsoft.AspNetCore.HttpLogging (1)
HttpLoggingServicesExtensions.cs (1)
56services.TryAddEnumerable(ServiceDescriptor.Singleton<IHttpLoggingInterceptor, T>());
Microsoft.AspNetCore.Identity (3)
IdentityBuilderExtensions.cs (2)
47builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<SecurityStampValidatorOptions>, PostConfigureSecurityStampValidatorOptions>()); 103builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<JsonOptions>, IdentityEndpointsJsonOptionsSetup>());
IdentityServiceCollectionExtensions.cs (1)
102services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<SecurityStampValidatorOptions>, PostConfigureSecurityStampValidatorOptions>());
Microsoft.AspNetCore.MiddlewareAnalysis (1)
AnalysisServiceCollectionExtensions.cs (1)
27services.TryAddEnumerable(ServiceDescriptor.Transient<IStartupFilter, AnalysisStartupFilter>());
Microsoft.AspNetCore.Mvc (2)
MvcServiceCollectionExtensions.cs (2)
146ServiceDescriptor.Singleton<IActionDescriptorChangeProvider, HotReloadService>()); 317ServiceDescriptor.Singleton<IActionDescriptorChangeProvider, HotReloadService>());
Microsoft.AspNetCore.Mvc.ApiExplorer (2)
DependencyInjection\EndpointMethodInfoApiExplorerServiceCollectionExtensions.cs (1)
31ServiceDescriptor.Transient<IApiDescriptionProvider, EndpointMetadataApiDescriptionProvider>());
DependencyInjection\MvcApiExplorerMvcCoreBuilderExtensions.cs (1)
40ServiceDescriptor.Transient<IApiDescriptionProvider, DefaultApiDescriptionProvider>());
Microsoft.AspNetCore.Mvc.Core (20)
DependencyInjection\MvcCoreMvcBuilderExtensions.cs (1)
132builder.Services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>());
DependencyInjection\MvcCoreMvcCoreBuilderExtensions.cs (2)
131ServiceDescriptor.Transient<IApplicationModelProvider, AuthorizationApplicationModelProvider>()); 149builder.Services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>());
DependencyInjection\MvcCoreServiceCollectionExtensions.cs (17)
135ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, MvcCoreMvcOptionsSetup>()); 137ServiceDescriptor.Transient<IPostConfigureOptions<MvcOptions>, MvcCoreMvcOptionsSetup>()); 139ServiceDescriptor.Transient<IConfigureOptions<ApiBehaviorOptions>, ApiBehaviorOptionsSetup>()); 141ServiceDescriptor.Transient<IConfigureOptions<RouteOptions>, MvcCoreRouteOptionsSetup>()); 149ServiceDescriptor.Transient<IApplicationModelProvider, DefaultApplicationModelProvider>()); 151ServiceDescriptor.Transient<IApplicationModelProvider, ApiBehaviorApplicationModelProvider>()); 153ServiceDescriptor.Transient<IActionDescriptorProvider, ControllerActionDescriptorProvider>()); 164services.TryAddEnumerable(ServiceDescriptor.Transient<IActionConstraintProvider, DefaultActionConstraintProvider>()); 167services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, ActionConstraintMatcherPolicy>()); 181ServiceDescriptor.Transient<IControllerPropertyActivator, DefaultControllerPropertyActivator>()); 189ServiceDescriptor.Transient<IActionInvokerProvider, ControllerActionInvokerProvider>()); 194ServiceDescriptor.Singleton<IFilterProvider, DefaultFilterProvider>()); 209services.TryAdd(ServiceDescriptor.Transient<ICompositeMetadataDetailsProvider>(s => 263services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, DynamicControllerEndpointMatcherPolicy>()); 264services.TryAddEnumerable(ServiceDescriptor.Singleton<IRequestDelegateFactory, ControllerRequestDelegateFactory>()); 273services.TryAddEnumerable(ServiceDescriptor.Singleton<IStartupFilter, MiddlewareFilterBuilderStartupFilter>()); 277services.TryAddEnumerable(ServiceDescriptor.Singleton<IProblemDetailsWriter, DefaultApiProblemDetailsWriter>());
Microsoft.AspNetCore.Mvc.Core.Test (6)
DependencyInjection\MvcCoreServiceCollectionExtensionsTest.cs (3)
40services.Add(ServiceDescriptor.Transient(serviceType.Key, mockType)); 68services.Add(ServiceDescriptor.Transient(serviceType, mockType)); 93foreach (var service in services)
Routing\ControllerLinkGeneratorExtensionsTest.cs (1)
220services.TryAddEnumerable(ServiceDescriptor.Singleton<EndpointDataSource>(new DefaultEndpointDataSource(endpoints)));
Routing\EndpointRoutingUrlHelperTest.cs (1)
287ServiceDescriptor.Singleton<EndpointDataSource>(new DefaultEndpointDataSource(endpoints)));
Routing\PageLinkGeneratorExtensionsTest.cs (1)
190services.TryAddEnumerable(ServiceDescriptor.Singleton<EndpointDataSource>(new DefaultEndpointDataSource(endpoints)));
Microsoft.AspNetCore.Mvc.Cors (1)
DependencyInjection\MvcCorsMvcCoreBuilderExtensions.cs (1)
71ServiceDescriptor.Transient<IApplicationModelProvider, CorsApplicationModelProvider>());
Microsoft.AspNetCore.Mvc.DataAnnotations (2)
DataAnnotationsLocalizationServices.cs (1)
25ServiceDescriptor.Transient
DependencyInjection\MvcDataAnnotationsMvcCoreBuilderExtensions.cs (1)
62ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, MvcDataAnnotationsMvcOptionsSetup>());
Microsoft.AspNetCore.Mvc.Formatters.Xml (4)
DependencyInjection\MvcXmlMvcBuilderExtensions.cs (2)
97ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, XmlDataContractSerializerMvcOptionsSetup>()); 104ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, XmlSerializerMvcOptionsSetup>());
DependencyInjection\MvcXmlMvcCoreBuilderExtensions.cs (2)
98ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, XmlDataContractSerializerMvcOptionsSetup>()); 105ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, XmlSerializerMvcOptionsSetup>());
Microsoft.AspNetCore.Mvc.FunctionalTests (2)
Infrastructure\MvcWebApplicationBuilderExtensions.cs (1)
34services.TryAddEnumerable(ServiceDescriptor.Singleton<IStartupFilter, CultureReplacerStartupFilter>());
TempDataInCookiesTest.cs (1)
44foreach (var serializer in tempDataSerializers)
Microsoft.AspNetCore.Mvc.Localization (3)
MvcLocalizationServices.cs (3)
41services.TryAdd(ServiceDescriptor.Singleton<IHtmlLocalizerFactory, HtmlLocalizerFactory>()); 42services.TryAdd(ServiceDescriptor.Transient(typeof(IHtmlLocalizer<>), typeof(HtmlLocalizer<>))); 43services.TryAdd(ServiceDescriptor.Transient<IViewLocalizer, ViewLocalizer>());
Microsoft.AspNetCore.Mvc.Localization.Test (7)
MvcLocalizationMvcBuilderExtensionsTest.cs (2)
46var service = services.FirstOrDefault( 125private ServiceDescriptor GetService(IServiceCollection services, Type serviceType)
MvcLocalizationMvcCoreBuilderExtensionsTest.cs (2)
46var service = services.FirstOrDefault( 125private ServiceDescriptor GetService(IServiceCollection services, Type serviceType)
MvcLocalizationServiceCollectionExtensionsTest.cs (3)
38collection.Add(ServiceDescriptor.Singleton(typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory))); 39collection.Add(ServiceDescriptor.Transient(typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>))); 40collection.Add(ServiceDescriptor.Transient(typeof(IViewLocalizer), typeof(TestViewLocalizer)));
Microsoft.AspNetCore.Mvc.NewtonsoftJson (5)
DependencyInjection\NewtonsoftJsonMvcCoreBuilderExtensions.cs (5)
60ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, NewtonsoftJsonMvcOptionsSetup>()); 62ServiceDescriptor.Transient<IApiDescriptionProvider, JsonPatchOperationsArrayProvider>()); 64var jsonResultExecutor = services.FirstOrDefault(f => 75var tempDataSerializer = services.FirstOrDefault(f => 89var jsonHelper = services.FirstOrDefault(
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (3)
DependencyInjection\NewtonsoftJsonMvcCoreBuilderExtensionsTest.cs (3)
44var jsonHelper = Assert.Single(services, d => d.ServiceType == typeof(IJsonHelper)); 59var tempDataSerializer = Assert.Single(services, d => d.ServiceType == typeof(TempDataSerializer)); 74var jsonResultExecutor = Assert.Single(services, d => d.ServiceType == typeof(IActionResultExecutor<JsonResult>));
Microsoft.AspNetCore.Mvc.Razor (3)
DependencyInjection\MvcRazorMvcCoreBuilderExtensions.cs (2)
126ServiceDescriptor.Transient<IConfigureOptions<MvcViewOptions>, MvcRazorMvcViewOptionsSetup>()); 129ServiceDescriptor.Transient<IConfigureOptions<RazorViewEngineOptions>, RazorViewEngineOptionsSetup>());
DependencyInjection\TagHelpersAsServices.cs (1)
27services.Replace(ServiceDescriptor.Transient<ITagHelperActivator, ServiceBasedTagHelperActivator>());
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (7)
DependencyInjection\RazorRuntimeCompilationMvcCoreBuilderExtensions.cs (7)
60ServiceDescriptor.Transient<IConfigureOptions<MvcRazorRuntimeCompilationOptions>, MvcRazorRuntimeCompilationOptionsSetup>()); 62var compilerProvider = services.FirstOrDefault(f => 75var actionDescriptorProvider = services.FirstOrDefault(f => 88ServiceDescriptor.Singleton<IActionDescriptorProvider, PageActionDescriptorProvider>()); 89services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, PageLoaderMatcherPolicy>()); 122ServiceDescriptor.Singleton<IPageRouteModelProvider, RazorProjectPageRouteModelProvider>()); 125ServiceDescriptor.Singleton<IActionDescriptorChangeProvider, PageActionDescriptorChangeProvider>());
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.Test (2)
DependencyInjection\RazorRuntimeCompilationMvcCoreBuilderExtensionsTest.cs (2)
27var serviceDescriptor = Assert.Single(services, service => service.ServiceType == typeof(IViewCompilerProvider)); 44var serviceDescriptor = Assert.Single(services, service => service.ServiceType == typeof(IActionDescriptorProvider));
Microsoft.AspNetCore.Mvc.Razor.Test (8)
DependencyInjection\MvcRazorMvcBuilderExtensionsTest.cs (4)
28var activatorDescriptor = Assert.Single(services.ToList(), d => d.ServiceType == typeof(ITagHelperActivator)); 54var tagHelperOne = Assert.Single(collection, t => t.ServiceType == typeof(TestTagHelperOne)); 58var tagHelperTwo = Assert.Single(collection, t => t.ServiceType == typeof(TestTagHelperTwo)); 62var activator = Assert.Single(collection, t => t.ServiceType == typeof(ITagHelperActivator));
DependencyInjection\MvcRazorMvcCoreBuilderExtensionsTest.cs (4)
68var activatorDescriptor = Assert.Single(services.ToList(), d => d.ServiceType == typeof(ITagHelperActivator)); 94var tagHelperOne = Assert.Single(collection, t => t.ServiceType == typeof(TestTagHelperOne)); 98var tagHelperTwo = Assert.Single(collection, t => t.ServiceType == typeof(TestTagHelperTwo)); 102var activator = Assert.Single(collection, t => t.ServiceType == typeof(ITagHelperActivator));
Microsoft.AspNetCore.Mvc.RazorPages (15)
DependencyInjection\MvcRazorPagesMvcCoreBuilderExtensions.cs (15)
83ServiceDescriptor.Transient<IConfigureOptions<RazorViewEngineOptions>, RazorPagesRazorViewEngineOptionsSetup>()); 86ServiceDescriptor.Transient<IConfigureOptions<RazorPagesOptions>, RazorPagesOptionsSetup>()); 89services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, DynamicPageEndpointMatcherPolicy>()); 94var actionDescriptorProvider = services.FirstOrDefault(f => 105ServiceDescriptor.Singleton<IActionDescriptorProvider, CompiledPageActionDescriptorProvider>()); 108ServiceDescriptor.Singleton<IPageRouteModelProvider, CompiledPageRouteModelProvider>()); 110services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, DynamicPageEndpointMatcherPolicy>()); 113ServiceDescriptor.Singleton<IPageApplicationModelProvider, DefaultPageApplicationModelProvider>()); 115ServiceDescriptor.Singleton<IPageApplicationModelProvider, AutoValidateAntiforgeryPageApplicationModelProvider>()); 117ServiceDescriptor.Singleton<IPageApplicationModelProvider, AuthorizationPageApplicationModelProvider>()); 119ServiceDescriptor.Singleton<IPageApplicationModelProvider, TempDataFilterPageApplicationModelProvider>()); 121ServiceDescriptor.Singleton<IPageApplicationModelProvider, ViewDataAttributePageApplicationModelProvider>()); 123ServiceDescriptor.Singleton<IPageApplicationModelProvider, ResponseCacheFilterApplicationModelProvider>()); 128ServiceDescriptor.Singleton<IActionInvokerProvider, PageActionInvokerProvider>()); 130ServiceDescriptor.Singleton<IRequestDelegateFactory, PageRequestDelegateFactory>());
Microsoft.AspNetCore.Mvc.Test (9)
MvcServiceCollectionExtensionsTest.cs (9)
65services.Add(ServiceDescriptor.Transient(serviceType.Key, mockType)); 149services.Add(ServiceDescriptor.Transient(serviceType, mockType)); 264foreach (var service in services) 310var descriptor = Assert.Single(services, d => d.ServiceType == typeof(ApplicationPartManager)); 338var descriptor = Assert.Single(services, d => d.ServiceType == typeof(ApplicationPartManager)); 364var descriptor = Assert.Single(services, d => d.ServiceType == typeof(ApplicationPartManager)); 388var descriptor = Assert.Single(services, d => d.ServiceType == typeof(ApplicationPartManager)); 436var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 648foreach ( var service in matches )
Microsoft.AspNetCore.Mvc.ViewFeatures (13)
DependencyInjection\MvcViewFeaturesMvcBuilderExtensions.cs (5)
53builder.Services.Replace(ServiceDescriptor.Singleton<IViewComponentActivator, ServiceBasedViewComponentActivator>()); 71var descriptor = ServiceDescriptor.Singleton(typeof(ITempDataProvider), typeof(SessionStateTempDataProvider)); 90var descriptor = ServiceDescriptor.Singleton(typeof(ITempDataProvider), typeof(CookieTempDataProvider));
DependencyInjection\MvcViewFeaturesMvcCoreBuilderExtensions.cs (8)
56var descriptor = ServiceDescriptor.Singleton(typeof(ITempDataProvider), typeof(CookieTempDataProvider)); 137ServiceDescriptor.Transient<IConfigureOptions<MvcViewOptions>, MvcViewOptionsSetup>()); 139ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, TempDataMvcOptionsSetup>()); 150ServiceDescriptor 188ServiceDescriptor.Transient<IApplicationModelProvider, TempDataApplicationModelProvider>()); 190ServiceDescriptor.Transient<IApplicationModelProvider, ViewDataAttributeApplicationModelProvider>()); 204ServiceDescriptor.Transient<IApplicationModelProvider, AntiforgeryApplicationModelProvider>());
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (14)
DependencyInjection\MvcViewFeaturesMvcBuilderExtensionsTest.cs (5)
31var descriptor = Assert.Single(builder.Services.ToList(), d => d.ServiceType == typeof(IViewComponentActivator)); 45var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider)); 74var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider)); 104var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider)); 119var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider));
DependencyInjection\MvcViewFeaturesMvcCoreBuilderExtensionsTest.cs (9)
23var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 38var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 69var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 101var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 117var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 133var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 149var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 165var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 181var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider));
Microsoft.AspNetCore.OpenApi (1)
Extensions\OpenApiServiceCollectionExtensions.cs (1)
121services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<JsonOptions>, OpenApiSchemaJsonOptions>());
Microsoft.AspNetCore.Routing (8)
DependencyInjection\RoutingServiceCollectionExtensions.cs (8)
31services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<RouteOptions>, RegexInlineRouteConstraintSetup>()); 59services.TryAdd(ServiceDescriptor.Transient<TreeRouteBuilder>(s => 71services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<RouteOptions>, ConfigureRouteOptions>( 105services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, HttpMethodMatcherPolicy>()); 106services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, HostMatcherPolicy>()); 107services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, AcceptsMatcherPolicy>()); 108services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, ContentEncodingNegotiationMatcherPolicy>()); 118services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<RouteHandlerOptions>, ConfigureRouteHandlerOptions>());
Microsoft.AspNetCore.Routing.Microbenchmarks (1)
EndpointRoutingBenchmarkBase.cs (1)
35ServiceDescriptor.Singleton<EndpointDataSource>(new DefaultEndpointDataSource(Endpoints)));
Microsoft.AspNetCore.Server.Kestrel (3)
WebHostBuilderKestrelExtensions.cs (3)
91services.TryAddEnumerable(ServiceDescriptor.Singleton<IHeartbeatHandler, PinnedBlockMemoryPoolFactory>(sp => sp.GetRequiredService<PinnedBlockMemoryPoolFactory>())); 136services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<KestrelServerOptions>, KestrelServerOptionsSetup>()); 172services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<KestrelServerOptions>, KestrelServerOptionsSetup>());
Microsoft.AspNetCore.SignalR (1)
SignalRDependencyInjectionExtensions.cs (1)
46services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<HubOptions>, HubOptionsSetup>());
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (1)
VersionStartup.cs (1)
24services.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol>(new VersionedJsonHubProtocol(1000)));
Microsoft.AspNetCore.SignalR.Microbenchmarks (1)
HubConnectionReceiveBenchmark.cs (1)
72hubConnectionBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(IHubProtocol), hubProtocol));
Microsoft.AspNetCore.SignalR.Protocols.Json (1)
JsonProtocolDependencyInjectionExtensions.cs (1)
38builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, JsonHubProtocol>());
Microsoft.AspNetCore.SignalR.Protocols.MessagePack (1)
MessagePackProtocolDependencyInjectionExtensions.cs (1)
41builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, MessagePackHubProtocol>());
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson (1)
NewtonsoftJsonProtocolDependencyInjectionExtensions.cs (1)
41builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, NewtonsoftJsonHubProtocol>());
Microsoft.AspNetCore.SignalR.Tests (2)
AddSignalRTests.cs (2)
178serviceCollection.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, CustomHubProtocol>()); 179serviceCollection.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, MessagePackHubProtocol>());
Microsoft.AspNetCore.SpaProxy (1)
SpaHostingStartup.cs (1)
29services.TryAddEnumerable(ServiceDescriptor.Singleton<IStartupFilter, SpaProxyStartupFilter>());
Microsoft.AspNetCore.Tests (2)
WebApplicationTests.cs (2)
1823Assert.Throws<InvalidOperationException>(() => builder.Services.Remove(ServiceDescriptor.Singleton(new Service()))); 1824Assert.Throws<InvalidOperationException>(() => builder.Services[0] = ServiceDescriptor.Singleton(new Service()));
Microsoft.Authentication.WebAssembly.Msal (1)
MsalWebAssemblyServiceCollectionExtensions.cs (1)
61services.TryAddEnumerable(ServiceDescriptor.Scoped<IPostConfigureOptions<RemoteAuthenticationOptions<MsalProviderOptions>>, MsalDefaultOptionsConfiguration>());
Microsoft.DotNet.Internal.DependencyInjection.Testing (2)
DependencyInjectionValidation.cs (2)
50foreach (ServiceDescriptor service in services) 145ServiceDescriptor parameterService = services.FirstOrDefault(s => IsMatchingServiceRegistration(s.ServiceType, p.ParameterType));
Microsoft.Extensions.AI.Tests (10)
ChatCompletion\DependencyInjectionPatterns.cs (4)
125ServiceDescriptor sd = Assert.Single(sc); 147ServiceDescriptor sd = Assert.Single(sc); 171ServiceDescriptor sd = sc[0]; 216ServiceDescriptor sd = sc[0];
Image\ImageGeneratorDependencyInjectionPatterns.cs (3)
125ServiceDescriptor sd = Assert.Single(sc); 147ServiceDescriptor sd = Assert.Single(sc); 163ServiceDescriptor sd = Assert.Single(sc);
SpeechToText\SpeechToTextClientDependencyInjectionPatterns.cs (3)
125ServiceDescriptor sd = Assert.Single(sc); 147ServiceDescriptor sd = Assert.Single(sc); 163ServiceDescriptor sd = Assert.Single(sc);
Microsoft.Extensions.AsyncState.Tests (1)
AsyncContextServiceCollectionExtensionsTests.cs (1)
29var serviceDescriptor = services.First(x => x.ServiceType == typeof(IAsyncContext<>));
Microsoft.Extensions.Caching.Memory (2)
MemoryCacheServiceCollectionExtensions.cs (2)
27services.TryAdd(ServiceDescriptor.Singleton<IMemoryCache, MemoryCache>()); 71services.TryAdd(ServiceDescriptor.Singleton<IDistributedCache, MemoryDistributedCache>());
Microsoft.Extensions.Caching.SqlServer (1)
SqlServerCachingServicesExtensions.cs (1)
37services.Add(ServiceDescriptor.Singleton<IDistributedCache, SqlServerCache>());
Microsoft.Extensions.Caching.SqlServer.Tests (2)
SqlServerCacheServicesExtensionsTest.cs (2)
24var serviceDescriptor = Assert.Single(services); 48var distributedCache = services.FirstOrDefault(desc => desc.ServiceType == typeof(IDistributedCache));
Microsoft.Extensions.Caching.StackExchangeRedis (1)
StackExchangeRedisCacheServiceCollectionExtensions.cs (1)
32services.Add(ServiceDescriptor.Singleton<IDistributedCache, RedisCacheImpl>());
Microsoft.Extensions.Caching.StackExchangeRedis.Tests (3)
CacheServiceExtensionsTests.cs (3)
34var distributedCache = services.FirstOrDefault(desc => desc.ServiceType == typeof(IDistributedCache)); 53var distributedCache = services.FirstOrDefault(desc => desc.ServiceType == typeof(IDistributedCache)); 124var distributedCache = services.FirstOrDefault(desc => desc.ServiceType == typeof(IDistributedCache));
Microsoft.Extensions.Compliance.Redaction (4)
RedactionBuilder.cs (4)
29Services.TryAddEnumerable(ServiceDescriptor.Singleton<Redactor>(ErasingRedactor.Instance)); 30Services.TryAddEnumerable(ServiceDescriptor.Singleton<Redactor>(NullRedactor.Instance)); 41Services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(Redactor), redactorType)); 51Services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(Redactor), typeof(T)));
Microsoft.Extensions.DependencyInjection (36)
DependencyInjectionEventSource.cs (2)
204foreach (ServiceDescriptor descriptor in provider.CallSiteFactory.Descriptors) 260private static void AppendServiceDescriptor(StringBuilder builder, ServiceDescriptor descriptor)
ServiceLookup\CallSiteFactory.cs (19)
17private readonly ServiceDescriptor[] _descriptors; 24public CallSiteFactory(ICollection<ServiceDescriptor> descriptors) 27_descriptors = new ServiceDescriptor[descriptors.Count]; 33internal ServiceDescriptor[] Descriptors => _descriptors; 37foreach (ServiceDescriptor descriptor in _descriptors) 152internal int? GetSlot(ServiceDescriptor serviceDescriptor) 166internal ServiceCallSite? GetCallSite(ServiceDescriptor serviceDescriptor, CallSiteChain callSiteChain) 300ServiceDescriptor descriptor = descriptors[i]; 464private ServiceCallSite? TryCreateExact(ServiceDescriptor descriptor, ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain, int slot) 477private ServiceCallSite CreateExact(ServiceDescriptor descriptor, ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain, int slot) 512private ServiceCallSite? TryCreateOpenGeneric(ServiceDescriptor descriptor, ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain, int slot, bool throwOnConstraintViolation) 533private ServiceCallSite? CreateOpenGeneric(ServiceDescriptor descriptor, ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain, int slot, bool throwOnConstraintViolation) 826private ServiceDescriptor? _item; 829private List<ServiceDescriptor>? _items; 831public ServiceDescriptor Last 859public ServiceDescriptor this[int index] 877public int GetSlot(ServiceDescriptor descriptor) 896public ServiceDescriptorCacheItem Add(ServiceDescriptor descriptor) 907newCacheItem._items = _items ?? new List<ServiceDescriptor>();
ServiceLookup\ServiceDescriptorExtensions.cs (7)
11public static bool HasImplementationInstance(this ServiceDescriptor serviceDescriptor) => GetImplementationInstance(serviceDescriptor) != null; 13public static bool HasImplementationFactory(this ServiceDescriptor serviceDescriptor) => GetImplementationFactory(serviceDescriptor) != null; 15public static bool HasImplementationType(this ServiceDescriptor serviceDescriptor) => GetImplementationType(serviceDescriptor) != null; 17public static object? GetImplementationInstance(this ServiceDescriptor serviceDescriptor) 24public static object? GetImplementationFactory(this ServiceDescriptor serviceDescriptor) 32public static Type? GetImplementationType(this ServiceDescriptor serviceDescriptor) 39public static bool TryGetImplementationType(this ServiceDescriptor serviceDescriptor, out Type? type)
ServiceLookup\ServiceIdentifier.cs (1)
26public static ServiceIdentifier FromDescriptor(ServiceDescriptor serviceDescriptor)
ServiceLookup\ServiceProviderEngineScope.cs (2)
319public List<ServiceDescriptor> ServiceDescriptors => new List<ServiceDescriptor>(_serviceProvider.RootProvider.CallSiteFactory.Descriptors);
ServiceProvider.cs (5)
52internal ServiceProvider(ICollection<ServiceDescriptor> serviceDescriptors, ServiceProviderOptions options) 76foreach (ServiceDescriptor serviceDescriptor in serviceDescriptors) 236private void ValidateService(ServiceDescriptor descriptor) 332public List<ServiceDescriptor> ServiceDescriptors => new List<ServiceDescriptor>(_serviceProvider.Root.RootProvider.CallSiteFactory.Descriptors);
Microsoft.Extensions.DependencyInjection.Abstractions (268)
Extensions\ServiceCollectionDescriptorExtensions.cs (55)
19/// <param name="descriptor">The <see cref="ServiceDescriptor"/> to add.</param> 23ServiceDescriptor descriptor) 33/// Adds a sequence of <see cref="ServiceDescriptor"/> to the <paramref name="collection"/>. 36/// <param name="descriptors">The <see cref="ServiceDescriptor"/>s to add.</param> 40IEnumerable<ServiceDescriptor> descriptors) 45foreach (ServiceDescriptor? descriptor in descriptors) 58/// <param name="descriptor">The <see cref="ServiceDescriptor"/> to add.</param> 61ServiceDescriptor descriptor) 85/// <param name="descriptors">The <see cref="ServiceDescriptor"/>s to add.</param> 88IEnumerable<ServiceDescriptor> descriptors) 93foreach (ServiceDescriptor? d in descriptors) 113var descriptor = ServiceDescriptor.Transient(service, service); 135var descriptor = ServiceDescriptor.Transient(service, implementationType); 157var descriptor = ServiceDescriptor.Transient(service, implementationFactory); 208services.TryAdd(ServiceDescriptor.Transient(implementationFactory)); 225var descriptor = ServiceDescriptor.Scoped(service, service); 247var descriptor = ServiceDescriptor.Scoped(service, implementationType); 269var descriptor = ServiceDescriptor.Scoped(service, implementationFactory); 320services.TryAdd(ServiceDescriptor.Scoped(implementationFactory)); 337var descriptor = ServiceDescriptor.Singleton(service, service); 359var descriptor = ServiceDescriptor.Singleton(service, implementationType); 381var descriptor = ServiceDescriptor.Singleton(service, implementationFactory); 433var descriptor = ServiceDescriptor.Singleton(serviceType: typeof(TService), implementationInstance: instance); 451services.TryAdd(ServiceDescriptor.Singleton(implementationFactory)); 455/// Adds a <see cref="ServiceDescriptor"/> if an existing descriptor with the same 456/// <see cref="ServiceDescriptor.ServiceType"/> and an implementation that does not already exist 460/// <param name="descriptor">The <see cref="ServiceDescriptor"/>.</param> 462/// Use <see cref="TryAddEnumerable(IServiceCollection, ServiceDescriptor)"/> when registering a service implementation of a 465/// <see cref="Add(IServiceCollection, ServiceDescriptor)"/> is not idempotent and can add 467/// <see cref="ServiceDescriptor"/> instances if called twice. Using 468/// <see cref="TryAddEnumerable(IServiceCollection, ServiceDescriptor)"/> will prevent registration 473ServiceDescriptor descriptor) 493ServiceDescriptor service = services[i]; 507/// Adds the specified <see cref="ServiceDescriptor"/>s if an existing descriptor with the same 508/// <see cref="ServiceDescriptor.ServiceType"/> and an implementation that does not already exist 512/// <param name="descriptors">The <see cref="ServiceDescriptor"/>s.</param> 514/// Use <see cref="TryAddEnumerable(IServiceCollection, ServiceDescriptor)"/> when registering a service 517/// <see cref="Add(IServiceCollection, ServiceDescriptor)"/> is not idempotent and can add 519/// <see cref="ServiceDescriptor"/> instances if called twice. Using 520/// <see cref="TryAddEnumerable(IServiceCollection, ServiceDescriptor)"/> will prevent registration 525IEnumerable<ServiceDescriptor> descriptors) 530foreach (ServiceDescriptor? d in descriptors) 541/// <param name="descriptor">The <see cref="ServiceDescriptor"/> to replace with.</param> 545ServiceDescriptor descriptor) 587ServiceDescriptor? descriptor = collection[i];
Extensions\ServiceCollectionDescriptorExtensions.Keyed.cs (24)
28var descriptor = ServiceDescriptor.KeyedTransient(service, serviceKey, service); 52var descriptor = ServiceDescriptor.KeyedTransient(service, serviceKey, implementationType); 76var descriptor = ServiceDescriptor.KeyedTransient(service, serviceKey, implementationFactory); 131services.TryAdd(ServiceDescriptor.KeyedTransient(serviceKey, implementationFactory)); 150var descriptor = ServiceDescriptor.KeyedScoped(service, serviceKey, service); 174var descriptor = ServiceDescriptor.KeyedScoped(service, serviceKey, implementationType); 198var descriptor = ServiceDescriptor.KeyedScoped(service, serviceKey, implementationFactory); 253services.TryAdd(ServiceDescriptor.KeyedScoped(serviceKey, implementationFactory)); 272var descriptor = ServiceDescriptor.KeyedSingleton(service, serviceKey, service); 296var descriptor = ServiceDescriptor.KeyedSingleton(service, serviceKey, implementationType); 320var descriptor = ServiceDescriptor.KeyedSingleton(service, serviceKey, implementationFactory); 375var descriptor = ServiceDescriptor.KeyedSingleton(serviceType: typeof(TService), serviceKey, implementationInstance: instance); 395services.TryAdd(ServiceDescriptor.KeyedSingleton(serviceKey, implementationFactory)); 422ServiceDescriptor? descriptor = collection[i];
IKeyedServiceProvider.cs (1)
28/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param>
IServiceCollection.cs (1)
11public interface IServiceCollection : IList<ServiceDescriptor>
IServiceProviderIsKeyedService.cs (1)
19/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param>
ServiceCollection.cs (14)
18private readonly List<ServiceDescriptor> _descriptors = new List<ServiceDescriptor>(); 28public ServiceDescriptor this[int index] 49public bool Contains(ServiceDescriptor item) 55public void CopyTo(ServiceDescriptor[] array, int arrayIndex) 61public bool Remove(ServiceDescriptor item) 68public IEnumerator<ServiceDescriptor> GetEnumerator() 73void ICollection<ServiceDescriptor>.Add(ServiceDescriptor item) 85public int IndexOf(ServiceDescriptor item) 91public void Insert(int index, ServiceDescriptor item) 146public ServiceDescriptor[] Items 150ServiceDescriptor[] items = new ServiceDescriptor[_services.Count];
ServiceCollectionServiceExtensions.cs (3)
570var serviceDescriptor = new ServiceDescriptor(serviceType, implementationInstance); 606var descriptor = new ServiceDescriptor(serviceType, implementationType, lifetime); 617var descriptor = new ServiceDescriptor(serviceType, implementationFactory, lifetime);
ServiceCollectionServiceExtensions.Keyed.cs (26)
21/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 50/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 80/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 105/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 130/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 155/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 185/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 214/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 243/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 273/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 298/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 323/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 348/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 378/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 407/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 436/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 466/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 491/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 516/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 541/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 571/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 600/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 619var serviceDescriptor = new ServiceDescriptor(serviceType, serviceKey, implementationInstance); 630/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 658var descriptor = new ServiceDescriptor(serviceType, serviceKey, implementationType, lifetime); 670var descriptor = new ServiceDescriptor(serviceType, serviceKey, implementationFactory, lifetime);
ServiceDescriptor.cs (143)
18/// Initializes a new instance of <see cref="ServiceDescriptor"/> with the specified <paramref name="implementationType"/>. 32/// Initializes a new instance of <see cref="ServiceDescriptor"/> with the specified <paramref name="implementationType"/>. 35/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 52/// Initializes a new instance of <see cref="ServiceDescriptor"/> with the specified <paramref name="instance"/> 65/// Initializes a new instance of <see cref="ServiceDescriptor"/> with the specified <paramref name="instance"/> 69/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 84/// Initializes a new instance of <see cref="ServiceDescriptor"/> with the specified <paramref name="factory"/>. 102/// Initializes a new instance of <see cref="ServiceDescriptor"/> with the specified <paramref name="factory"/>. 105/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 354/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 360/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 361public static ServiceDescriptor Transient<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>() 369/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 375/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 376/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 377public static ServiceDescriptor KeyedTransient<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(object? serviceKey) 385/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 391/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 392public static ServiceDescriptor Transient( 403/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 408/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 410/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 411public static ServiceDescriptor KeyedTransient( 423/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 431/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 432public static ServiceDescriptor Transient<TService, TImplementation>( 443/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 450/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 452/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 453public static ServiceDescriptor KeyedTransient<TService, TImplementation>( 465/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 471/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 472public static ServiceDescriptor Transient<TService>(Func<IServiceProvider, TService> implementationFactory) 481/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 486/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 488/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 489public static ServiceDescriptor KeyedTransient<TService>(object? serviceKey, Func<IServiceProvider, object?, TService> implementationFactory) 498/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 504/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 505public static ServiceDescriptor Transient(Type service, Func<IServiceProvider, object> implementationFactory) 514/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 519/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 521/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 522public static ServiceDescriptor KeyedTransient(Type service, object? serviceKey, Func<IServiceProvider, object?, object> implementationFactory) 531/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 537/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 538public static ServiceDescriptor Scoped<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>() 546/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 552/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 553/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 554public static ServiceDescriptor KeyedScoped<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(object? serviceKey) 562/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 568/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 569public static ServiceDescriptor Scoped( 577/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 582/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 584/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 585public static ServiceDescriptor KeyedScoped( 594/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 602/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 603public static ServiceDescriptor Scoped<TService, TImplementation>( 614/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 621/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 623/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 624public static ServiceDescriptor KeyedScoped<TService, TImplementation>( 636/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 642/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 643public static ServiceDescriptor Scoped<TService>(Func<IServiceProvider, TService> implementationFactory) 652/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 657/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 659/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 660public static ServiceDescriptor KeyedScoped<TService>(object? serviceKey, Func<IServiceProvider, object?, TService> implementationFactory) 669/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 675/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 676public static ServiceDescriptor Scoped(Type service, Func<IServiceProvider, object> implementationFactory) 685/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 690/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 692/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 693public static ServiceDescriptor KeyedScoped(Type service, object? serviceKey, Func<IServiceProvider, object?, object> implementationFactory) 702/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 708/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 709public static ServiceDescriptor Singleton<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>() 717/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 723/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 724/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 725public static ServiceDescriptor KeyedSingleton<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>( 734/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 740/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 741public static ServiceDescriptor Singleton( 752/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 757/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 759/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 760public static ServiceDescriptor KeyedSingleton( 772/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 780/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 781public static ServiceDescriptor Singleton<TService, TImplementation>( 792/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 799/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 801/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 802public static ServiceDescriptor KeyedSingleton<TService, TImplementation>( 814/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 820/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 821public static ServiceDescriptor Singleton<TService>(Func<IServiceProvider, TService> implementationFactory) 830/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 835/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 837/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 838public static ServiceDescriptor KeyedSingleton<TService>( 849/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 855/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 856public static ServiceDescriptor Singleton( 867/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 872/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 874/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 875public static ServiceDescriptor KeyedSingleton( 887/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 893/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 894public static ServiceDescriptor Singleton<TService>(TService implementationInstance) 903/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 908/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 910/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 911public static ServiceDescriptor KeyedSingleton<TService>( 922/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 928/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 929public static ServiceDescriptor Singleton( 940/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 945/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 947/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 948public static ServiceDescriptor KeyedSingleton( 959private static ServiceDescriptor DescribeKeyed<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>( 973/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 980/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 981public static ServiceDescriptor Describe( 990/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 995/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 998/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 999public static ServiceDescriptor DescribeKeyed( 1009/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 1016/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 1017public static ServiceDescriptor Describe(Type serviceType, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime) 1023/// Creates an instance of <see cref="ServiceDescriptor"/> with the specified 1028/// <param name="serviceKey">The <see cref="ServiceDescriptor.ServiceKey"/> of the service.</param> 1031/// <returns>A new instance of <see cref="ServiceDescriptor"/>.</returns> 1032public static ServiceDescriptor DescribeKeyed(Type serviceType, object? serviceKey, Func<IServiceProvider, object?, object> implementationFactory, ServiceLifetime lifetime)
Microsoft.Extensions.DependencyInjection.AutoActivation (16)
AutoActivationExtensions.cs (8)
234services.TryAddAndActivate(ServiceDescriptor.Singleton(serviceType, serviceType)); 252services.TryAddAndActivate(ServiceDescriptor.Singleton(serviceType, implementationType)); 267services.TryAddAndActivate(ServiceDescriptor.Singleton(serviceType, implementationFactory)); 280services.TryAddAndActivate<TService>(ServiceDescriptor.Singleton<TService, TService>()); 295services.TryAddAndActivate<TService>(ServiceDescriptor.Singleton<TService, TImplementation>()); 310services.TryAddAndActivate<TService>(ServiceDescriptor.Singleton<TService>(implementationFactory)); 313private static void TryAddAndActivate<TService>(this IServiceCollection services, ServiceDescriptor descriptor) 325private static void TryAddAndActivate(this IServiceCollection services, ServiceDescriptor descriptor)
AutoActivationExtensions.Keyed.cs (8)
252services.TryAddAndActivateKeyed(ServiceDescriptor.KeyedSingleton(serviceType, serviceKey, serviceType)); 272services.TryAddAndActivateKeyed(ServiceDescriptor.KeyedSingleton(serviceType, serviceKey, implementationType)); 292services.TryAddAndActivateKeyed(ServiceDescriptor.KeyedSingleton(serviceType, serviceKey, implementationFactory)); 308services.TryAddAndActivateKeyed<TService>(ServiceDescriptor.KeyedSingleton<TService, TService>(serviceKey)); 326services.TryAddAndActivateKeyed<TService>(ServiceDescriptor.KeyedSingleton<TService, TImplementation>(serviceKey)); 345services.TryAddAndActivateKeyed<TService>(ServiceDescriptor.KeyedSingleton<TService>(serviceKey, implementationFactory)); 348private static void TryAddAndActivateKeyed<TService>(this IServiceCollection services, ServiceDescriptor descriptor) 360private static void TryAddAndActivateKeyed(this IServiceCollection services, ServiceDescriptor descriptor)
Microsoft.Extensions.Diagnostics.Abstractions (2)
Metrics\MetricsBuilderExtensions.Listeners.cs (2)
25builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IMetricsListener, T>()); 38builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton(listener));
Microsoft.Extensions.Diagnostics.ExceptionSummarization (1)
ExceptionSummarizationBuilder.cs (1)
22Services.TryAddEnumerable(ServiceDescriptor.Singleton<IExceptionSummaryProvider, T>());
Microsoft.Extensions.Diagnostics.HealthChecks (1)
DependencyInjection\HealthCheckServiceCollectionExtensions.cs (1)
29services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, HealthCheckPublisherHostedService>());
Microsoft.Extensions.Diagnostics.ResourceMonitoring (2)
ResourceMonitorBuilder.cs (2)
20services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, ResourceMonitorService>(static sp => sp.GetRequiredService<ResourceMonitorService>())); 32Services.TryAddEnumerable(ServiceDescriptor.Singleton<IResourceUtilizationPublisher, T>());
Microsoft.Extensions.Diagnostics.Testing (2)
Logging\FakeLoggerBuilderExtensions.cs (2)
30builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, FakeLoggerProvider>()); 48builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, FakeLoggerProvider>());
Microsoft.Extensions.Hosting.Abstractions (2)
ServiceCollectionHostedServiceExtensions.cs (2)
38services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, THostedService>()); 66services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService>(implementationFactory));
Microsoft.Extensions.Http (19)
DependencyInjection\DefaultHttpClientBuilderServiceCollection.cs (8)
25public void Add(ServiceDescriptor item) 59public ServiceDescriptor this[int index] 67public bool Contains(ServiceDescriptor item) => _services.Contains(item); 68public void CopyTo(ServiceDescriptor[] array, int arrayIndex) => _services.CopyTo(array, arrayIndex); 69public IEnumerator<ServiceDescriptor> GetEnumerator() => _services.GetEnumerator(); 70public int IndexOf(ServiceDescriptor item) => _services.IndexOf(item); 71public void Insert(int index, ServiceDescriptor item) => _services.Insert(index, item); 72public bool Remove(ServiceDescriptor item) => _services.Remove(item);
DependencyInjection\DefaultHttpClientConfigurationTracker.cs (1)
8public ServiceDescriptor? InsertDefaultsAfterDescriptor { get; set; }
DependencyInjection\HttpClientFactoryServiceCollectionExtensions.cs (4)
47services.TryAdd(ServiceDescriptor.Transient(typeof(ITypedHttpClientFactory<>), typeof(DefaultTypedHttpClientFactory<>))); 48services.TryAdd(ServiceDescriptor.Singleton(typeof(DefaultTypedHttpClientFactory<>.Cache), typeof(DefaultTypedHttpClientFactory<>.Cache))); 53services.TryAddEnumerable(ServiceDescriptor.Singleton<IHttpMessageHandlerBuilderFilter, LoggingHttpMessageHandlerBuilderFilter>()); 55services.TryAddEnumerable(ServiceDescriptor.Singleton<IHttpMessageHandlerBuilderFilter, MetricsFactoryHttpMessageHandlerFilter>());
DependencyInjection\HttpClientKeyedLifetime.cs (6)
15public ServiceDescriptor Client { get; } 16public ServiceDescriptor Handler { get; } 20private HttpClientKeyedLifetime(object serviceKey, ServiceDescriptor client, ServiceDescriptor handler) 31Client = ServiceDescriptor.DescribeKeyed(typeof(HttpClient), ServiceKey, CreateKeyedClient, lifetime); 32Handler = ServiceDescriptor.DescribeKeyed(typeof(HttpMessageHandler), ServiceKey, CreateKeyedHandler, lifetime);
Microsoft.Extensions.Http.Diagnostics.PerformanceTests (6)
HttpClientFactory.cs (6)
18services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, DropMessageLoggerProvider>()); 42services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, DropMessageLoggerProvider>()); 65services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, DropMessageLoggerProvider>()); 92services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, DropMessageLoggerProvider>()); 115services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, DropMessageLoggerProvider>()); 138services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, DropMessageLoggerProvider>());
Microsoft.Extensions.Http.Polly (3)
DependencyInjection\PollyServiceCollectionExtensions.cs (3)
39services.TryAddEnumerable(ServiceDescriptor.Singleton<IPolicyRegistry<string>>(registry)); 40services.TryAddEnumerable(ServiceDescriptor.Singleton<IReadOnlyPolicyRegistry<string>>(registry)); 44services.TryAddEnumerable(ServiceDescriptor.Singleton<IConcurrentPolicyRegistry<string>>(concurrentRegistry));
Microsoft.Extensions.Http.Resilience (2)
Resilience\ResilienceHttpClientBuilderExtensions.Resilience.cs (2)
173public static readonly ServiceDescriptor ServiceDescriptor = ServiceDescriptor.Singleton<Marker, Marker>();
Microsoft.Extensions.Logging (4)
LoggingBuilderExtensions.cs (1)
24builder.Services.Add(ServiceDescriptor.Singleton<IConfigureOptions<LoggerFilterOptions>>(
LoggingServiceCollectionExtensions.cs (3)
38services.TryAdd(ServiceDescriptor.Singleton<ILoggerFactory, LoggerFactory>()); 39services.TryAdd(ServiceDescriptor.Singleton(typeof(ILogger<>), typeof(Logger<>))); 41services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<LoggerFilterOptions>>(
Microsoft.Extensions.Logging.AzureAppServices (2)
AzureAppServicesLoggerFactoryExtensions.cs (2)
11using static Microsoft.Extensions.DependencyInjection.ServiceDescriptor; 90private static bool TryAddEnumerable(IServiceCollection collection, ServiceDescriptor descriptor)
Microsoft.Extensions.Logging.Configuration (2)
LoggerProviderConfigurationExtensions.cs (2)
29services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<TOptions>, LoggerProviderConfigureOptions<TOptions, TProvider>>()); 30services.TryAddEnumerable(ServiceDescriptor.Singleton<IOptionsChangeTokenSource<TOptions>, LoggerProviderOptionsChangeTokenSource<TOptions, TProvider>>());
Microsoft.Extensions.Logging.Console (6)
ConsoleLoggerExtensions.cs (6)
37builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, ConsoleLoggerProvider>()); 39builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<ConsoleLoggerOptions>, ConsoleLoggerConfigureOptions>()); 40builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IOptionsChangeTokenSource<ConsoleLoggerOptions>, LoggerProviderOptionsChangeTokenSource<ConsoleLoggerOptions, ConsoleLoggerProvider>>()); 163builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ConsoleFormatter, TFormatter>()); 164builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<TOptions>, TConfigureOptions>()); 165builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IOptionsChangeTokenSource<TOptions>, ConsoleLoggerFormatterOptionsChangeTokenSource<TFormatter, TOptions>>());
Microsoft.Extensions.Logging.Debug (1)
DebugLoggerFactoryExtensions.cs (1)
53builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, DebugLoggerProvider>());
Microsoft.Extensions.Logging.EventLog (4)
EventLoggerFactoryExtensions.cs (4)
63builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, EventLogLoggerProvider>()); 64builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<EventLogSettings>, EventLogConfigureOptions>()); 65builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IOptionsChangeTokenSource<EventLogSettings>, LoggerProviderOptionsChangeTokenSource<EventLogSettings, EventLogLoggerProvider>>()); 81builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider>(new EventLogLoggerProvider(settings)));
Microsoft.Extensions.Logging.EventSource (3)
EventSourceLoggerFactoryExtensions.cs (3)
50builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, EventSourceLoggerProvider>()); 51builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<LoggerFilterOptions>, EventLogFiltersConfigureOptions>()); 52builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IOptionsChangeTokenSource<LoggerFilterOptions>, EventLogFiltersConfigureOptionsChangeSource>());
Microsoft.Extensions.ML (1)
ServiceCollectionExtensions.cs (1)
83.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<MLOptions>, PostMLContextOptionsConfiguration>());
Microsoft.Extensions.Options (6)
OptionsServiceCollectionExtensions.cs (6)
26services.TryAdd(ServiceDescriptor.Singleton(typeof(IOptions<>), typeof(UnnamedOptionsManager<>))); 27services.TryAdd(ServiceDescriptor.Scoped(typeof(IOptionsSnapshot<>), typeof(OptionsManager<>))); 28services.TryAdd(ServiceDescriptor.Singleton(typeof(IOptionsMonitor<>), typeof(OptionsMonitor<>))); 29services.TryAdd(ServiceDescriptor.Transient(typeof(IOptionsFactory<>), typeof(OptionsFactory<>))); 30services.TryAdd(ServiceDescriptor.Singleton(typeof(IOptionsMonitorCache<>), typeof(OptionsCache<>))); 72services.AddOptions().TryAddEnumerable(ServiceDescriptor.Singleton<IValidateOptions<TOptions>, TValidateOptions>());
Microsoft.Extensions.Options.Contextual (3)
ContextualOptionsServiceCollectionExtensions.cs (3)
29services.TryAdd(ServiceDescriptor.Singleton(typeof(IContextualOptionsFactory<>), typeof(ContextualOptionsFactory<>))); 30services.TryAdd(ServiceDescriptor.Singleton(typeof(IContextualOptions<,>), typeof(ContextualOptions<,>))); 31services.TryAdd(ServiceDescriptor.Singleton(typeof(INamedContextualOptions<,>), typeof(ContextualOptions<,>)));
Microsoft.Extensions.ServiceDiscovery (1)
ServiceDiscoveryHttpClientBuilderExtensions.cs (1)
54services.TryAddEnumerable(ServiceDescriptor.Singleton<IHttpMessageHandlerBuilderFilter, DisableGrpcLoadBalancingFilter>());
Microsoft.Extensions.Telemetry (3)
Logging\LoggingEnrichmentExtensions.cs (1)
72services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerFactory, ExtendedLoggerFactory>());
Sampling\SamplingLoggerBuilderExtensions.cs (2)
130builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerFactory, ExtendedLoggerFactory>()); 148builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerFactory, ExtendedLoggerFactory>());
Microsoft.Maui (26)
Hosting\Dispatching\AppHostBuilderExtensions.cs (2)
22 builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IMauiInitializeService, ApplicationDispatcherInitializer>()); 27 builder.Services.TryAddEnumerable(ServiceDescriptor.Scoped<IMauiInitializeScopedService, DispatcherInitializer>());
Hosting\EssentialsMauiAppBuilderExtensions.cs (1)
91 builder.Services.TryAddEnumerable(ServiceDescriptor.Transient<IMauiInitializeService, EssentialsInitializer>());
Hosting\Fonts\FontsMauiAppBuilderExtensions.cs (1)
38 builder.Services.TryAddEnumerable(ServiceDescriptor.Transient<IMauiInitializeService, FontInitializer>());
Hosting\IMauiServiceCollection.cs (1)
9 bool TryGetService(Type serviceType, out ServiceDescriptor? descriptor);
Hosting\Internal\MauiFactory.cs (4)
17 readonly ConcurrentDictionary<ServiceDescriptor, object?> _singletons; 22 _singletons = new ConcurrentDictionary<ServiceDescriptor, object?>(); 33 if (!_collection.TryGetService(serviceType, out ServiceDescriptor? descriptor) || descriptor == null) 50 object? CreateInstance(ServiceDescriptor item)
Hosting\Internal\MauiHandlersFactory.cs (1)
31 InternalCollection.TryGetService(GetVirtualViewHandlerServiceType(iview), out ServiceDescriptor? serviceDescriptor);
Hosting\Internal\MauiServiceCollection.cs (14)
11 readonly List<ServiceDescriptor> _descriptors = new List<ServiceDescriptor>(); 12 readonly Dictionary<Type, ServiceDescriptor> _descriptorDictionary = new Dictionary<Type, ServiceDescriptor>(); 18 public ServiceDescriptor this[int index] 24 public void Add(ServiceDescriptor item) 39 public bool Contains(ServiceDescriptor item) => 42 public IEnumerator<ServiceDescriptor> GetEnumerator() => 48 public bool Remove(ServiceDescriptor item) 56 public void CopyTo(ServiceDescriptor[] array, int arrayIndex) => 59 public int IndexOf(ServiceDescriptor item) => _descriptors.IndexOf(item); 61 public void Insert(int index, ServiceDescriptor item) 69 var descriptor = _descriptors[index]; 74 public bool TryGetService(Type serviceType, out ServiceDescriptor? descriptor) =>
Hosting\MauiAppBuilder.cs (2)
179 Services.TryAdd(ServiceDescriptor.Singleton<ILoggerFactory, NullLoggerFactory>()); 180 Services.TryAdd(ServiceDescriptor.Singleton(typeof(ILogger<>), typeof(NullLogger<>)));
Microsoft.Maui.Controls.Compatibility (1)
AppHostBuilderExtensions.cs (1)
117 builder.Services.TryAddEnumerable(ServiceDescriptor.Transient<IMauiInitializeService, MauiCompatInitializer>());
Microsoft.ML.AutoML (2)
AutoMLExperiment\AutoMLExperiment.cs (2)
177var descriptor = ServiceDescriptor.Singleton<ITuner>(factory);