349 references to ServiceLifetime
Aspire.Azure.AI.OpenAI.Tests (2)
ConformanceTests.cs (2)
19protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Data.Tables.Tests (2)
ConformanceTests.cs (2)
23protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Messaging.ServiceBus.Tests (2)
ConformanceTests.cs (2)
20protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Messaging.WebPubSub.Tests (2)
ConformanceTests.cs (2)
20protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Search.Documents.Tests (2)
ConformanceTests.cs (2)
19protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Security.KeyVault.Tests (2)
ConformanceTests.cs (2)
22protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Storage.Blobs.Tests (2)
ConformanceTests.cs (2)
23protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Storage.Queues.Tests (2)
ConformanceTests.cs (2)
23protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Components.Common.Tests (4)
ConformanceTests.cs (4)
25protected abstract ServiceLifetime ServiceLifetime { get; } 196case ServiceLifetime.Singleton: 200case ServiceLifetime.Scoped: 204case ServiceLifetime.Transient:
Aspire.Confluent.Kafka.Tests (4)
ConsumerConformanceTests.cs (2)
14protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
ProducerConformanceTests.cs (2)
15protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Elastic.Clients.Elasticsearch.Tests (2)
ConformanceTests.cs (2)
19protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Hosting.Testing.Tests (1)
ResourceLoggerForwarderServiceTests.cs (1)
26&& sd.Lifetime == ServiceLifetime.Singleton);
Aspire.Microsoft.Azure.Cosmos.Tests (2)
ConformanceTests.cs (2)
15protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Microsoft.Data.SqlClient.Tests (2)
ConformanceTests.cs (2)
20protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Scoped;
Aspire.Microsoft.EntityFrameworkCore.Cosmos.Tests (4)
ConformanceTests.cs (2)
17protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichCosmosDbTests.cs (2)
107}, contextLifetime: ServiceLifetime.Singleton); 113Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Microsoft.EntityFrameworkCore.SqlServer.Tests (4)
ConformanceTests.cs (2)
22protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichSqlServerTests.cs (2)
250}, contextLifetime: ServiceLifetime.Singleton); 256Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Milvus.Client.Tests (2)
ConformanceTests.cs (2)
32protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.MongoDB.Driver.Tests (2)
ConformanceTests.cs (2)
18protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.MySqlConnector.Tests (2)
ConformanceTests.cs (2)
20protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.NATS.Net.Tests (2)
ConformanceTests.cs (2)
27protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (4)
ConformanceTests.cs (2)
21protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichNpgsqlTests.cs (2)
258}, contextLifetime: ServiceLifetime.Singleton); 264Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Npgsql.Tests (2)
ConformanceTests.cs (2)
20protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.OpenAI.Tests (2)
ConformanceTests.cs (2)
18protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Oracle.EntityFrameworkCore.Tests (4)
ConformanceTests.cs (2)
27protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichOracleDatabaseTests.cs (2)
250}, contextLifetime: ServiceLifetime.Singleton); 256Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Pomelo.EntityFrameworkCore.MySql.Tests (4)
ConformanceTests.cs (2)
23protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichMySqlTests.cs (2)
263}, contextLifetime: ServiceLifetime.Singleton); 269Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Qdrant.Client.Tests (2)
ConformanceTests.cs (2)
21protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.RabbitMQ.Client.Tests (2)
ConformanceTests.cs (2)
24protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.StackExchange.Redis.Tests (2)
ConformanceTests.cs (2)
20protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Microsoft.AspNetCore.AsyncState.Tests (2)
AsyncStateHttpContextExtensionsTests.cs (2)
29Assert.Equal(ServiceLifetime.Singleton, serviceDescriptor.Lifetime); 32Assert.Equal(ServiceLifetime.Singleton, serviceDescriptor.Lifetime);
Microsoft.AspNetCore.DataProtection (2)
DataProtectionBuilderExtensions.cs (2)
81/// Registrations are additive. The factory is registered as <see cref="ServiceLifetime.Singleton"/>. 107/// Registrations are additive. The factory is registered as <see cref="ServiceLifetime.Singleton"/>.
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (1)
DatabaseDeveloperPageExceptionFilterServiceExtensions.cs (1)
30services.TryAddEnumerable(new ServiceDescriptor(typeof(IDeveloperPageExceptionFilter), typeof(DatabaseDeveloperPageExceptionFilter), ServiceLifetime.Singleton));
Microsoft.AspNetCore.Http.Tests (1)
HttpServiceCollectionExtensionsTests.cs (1)
21Assert.Equal(ServiceLifetime.Singleton, descriptor.Lifetime);
Microsoft.AspNetCore.Identity.FunctionalTests (1)
Infrastructure\FunctionalTestsServiceCollectionExtensions.cs (1)
24ServiceLifetime.Scoped);
Microsoft.AspNetCore.Mvc.Core.Test (3)
DependencyInjection\MvcBuilderExtensionsTest.cs (3)
100Assert.Equal(ServiceLifetime.Transient, services[0].Lifetime); 104Assert.Equal(ServiceLifetime.Transient, services[1].Lifetime); 108Assert.Equal(ServiceLifetime.Transient, services[2].Lifetime);
Microsoft.AspNetCore.Mvc.Localization.Test (14)
MvcLocalizationMvcBuilderExtensionsTest.cs (7)
49Assert.Equal(ServiceLifetime.Singleton, service.Lifetime); 55Assert.Equal(ServiceLifetime.Transient, service.Lifetime); 62Assert.Equal(ServiceLifetime.Transient, service.Lifetime); 67Assert.Equal(ServiceLifetime.Singleton, service.Lifetime); 72Assert.Equal(ServiceLifetime.Singleton, service.Lifetime); 77Assert.Equal(ServiceLifetime.Transient, service.Lifetime); 82Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
MvcLocalizationMvcCoreBuilderExtensionsTest.cs (7)
49Assert.Equal(ServiceLifetime.Singleton, service.Lifetime); 55Assert.Equal(ServiceLifetime.Transient, service.Lifetime); 62Assert.Equal(ServiceLifetime.Transient, service.Lifetime); 67Assert.Equal(ServiceLifetime.Transient, service.Lifetime); 72Assert.Equal(ServiceLifetime.Singleton, service.Lifetime); 77Assert.Equal(ServiceLifetime.Transient, service.Lifetime); 82Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
Microsoft.AspNetCore.Mvc.Razor.Test (6)
DependencyInjection\MvcRazorMvcBuilderExtensionsTest.cs (3)
56Assert.Equal(ServiceLifetime.Transient, tagHelperOne.Lifetime); 60Assert.Equal(ServiceLifetime.Transient, tagHelperTwo.Lifetime); 64Assert.Equal(ServiceLifetime.Transient, activator.Lifetime);
DependencyInjection\MvcRazorMvcCoreBuilderExtensionsTest.cs (3)
96Assert.Equal(ServiceLifetime.Transient, tagHelperOne.Lifetime); 100Assert.Equal(ServiceLifetime.Transient, tagHelperTwo.Lifetime); 104Assert.Equal(ServiceLifetime.Transient, activator.Lifetime);
Microsoft.AspNetCore.Mvc.Test (3)
MvcServiceCollectionExtensionsTest.cs (3)
311Assert.Equal(ServiceLifetime.Singleton, descriptor.Lifetime); 339Assert.Equal(ServiceLifetime.Singleton, descriptor.Lifetime); 365Assert.Equal(ServiceLifetime.Singleton, descriptor.Lifetime);
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (3)
DependencyInjection\MvcViewFeaturesMvcBuilderExtensionsTest.cs (3)
147Assert.Equal(ServiceLifetime.Transient, collection[0].Lifetime); 151Assert.Equal(ServiceLifetime.Transient, collection[1].Lifetime); 155Assert.Equal(ServiceLifetime.Singleton, collection[2].Lifetime);
Microsoft.AspNetCore.OpenApi.Tests (18)
Extensions\OpenApiServiceCollectionExtensionsTests.cs (18)
38Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 39Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 40Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 72Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 73Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 74Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 105Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 106Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 107Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 138Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 139Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 140Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 160Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 161Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 162Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 184Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 185Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 186Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton);
Microsoft.DotNet.Internal.DependencyInjection.Testing (6)
DependencyInjectionValidation.cs (6)
70if (!IsTypeResolvable(scopedType, services, allErrors, ServiceLifetime.Scoped)) 78if (!IsTypeResolvable(scopedType, services, allErrors, ServiceLifetime.Singleton)) 94ServiceLifetime serviceLifetime) 129ServiceLifetime serviceLifetime, 148if (serviceLifetime == ServiceLifetime.Singleton && 149parameterService.Lifetime == ServiceLifetime.Scoped)
Microsoft.Extensions.AsyncState.Tests (3)
AsyncContextServiceCollectionExtensionsTests.cs (3)
30Assert.Equal(ServiceLifetime.Singleton, serviceDescriptor.Lifetime); 33Assert.Equal(ServiceLifetime.Singleton, serviceDescriptor.Lifetime); 36Assert.Equal(ServiceLifetime.Singleton, serviceDescriptor.Lifetime);
Microsoft.Extensions.Caching.SqlServer.Tests (2)
SqlServerCacheServicesExtensionsTest.cs (2)
27Assert.Equal(ServiceLifetime.Singleton, serviceDescriptor.Lifetime); 51Assert.Equal(ServiceLifetime.Scoped, distributedCache.Lifetime);
Microsoft.Extensions.Caching.StackExchangeRedis.Tests (3)
CacheServiceExtensionsTests.cs (3)
29Assert.Equal(ServiceLifetime.Singleton, distributedCache.Lifetime); 48Assert.Equal(ServiceLifetime.Scoped, distributedCache.Lifetime); 119Assert.Equal(ServiceLifetime.Scoped, distributedCache.Lifetime);
Microsoft.Extensions.DependencyInjection (11)
DependencyInjectionEventSource.cs (3)
198case ServiceLifetime.Singleton: 201case ServiceLifetime.Scoped: 204case ServiceLifetime.Transient:
ServiceLookup\CallSiteValidator.cs (4)
28nameof(ServiceLifetime.Scoped).ToLowerInvariant())); 35nameof(ServiceLifetime.Scoped).ToLowerInvariant())); 59nameof(ServiceLifetime.Scoped).ToLowerInvariant(), 60nameof(ServiceLifetime.Singleton).ToLowerInvariant()
ServiceLookup\ResultCache.cs (4)
23public ResultCache(ServiceLifetime lifetime, ServiceIdentifier serviceIdentifier, int slot) 27case ServiceLifetime.Singleton: 30case ServiceLifetime.Scoped: 33case ServiceLifetime.Transient:
Microsoft.Extensions.DependencyInjection.Abstractions (183)
Extensions\ServiceCollectionDescriptorExtensions.cs (19)
100/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 117/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 138/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 159/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 173/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 190/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 206/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 223/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 244/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 265/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 279/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 296/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 312/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 329/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 350/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 371/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 385/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 402/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 420/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service
Extensions\ServiceCollectionDescriptorExtensions.Keyed.cs (19)
13/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 32/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 55/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 78/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 93/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 111/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 129/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 148/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 171/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 194/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 209/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 227/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 245/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 264/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 287/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 310/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 325/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 343/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 362/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service
ServiceCollectionServiceExtensions.cs (31)
23/// <seealso cref="ServiceLifetime.Transient"/> 33return Add(services, serviceType, implementationType, ServiceLifetime.Transient); 45/// <seealso cref="ServiceLifetime.Transient"/> 55return Add(services, serviceType, implementationFactory, ServiceLifetime.Transient); 67/// <seealso cref="ServiceLifetime.Transient"/> 84/// <seealso cref="ServiceLifetime.Transient"/> 102/// <seealso cref="ServiceLifetime.Transient"/> 120/// <seealso cref="ServiceLifetime.Transient"/> 143/// <seealso cref="ServiceLifetime.Transient"/> 165/// <seealso cref="ServiceLifetime.Scoped"/> 175return Add(services, serviceType, implementationType, ServiceLifetime.Scoped); 187/// <seealso cref="ServiceLifetime.Scoped"/> 197return Add(services, serviceType, implementationFactory, ServiceLifetime.Scoped); 209/// <seealso cref="ServiceLifetime.Scoped"/> 226/// <seealso cref="ServiceLifetime.Scoped"/> 244/// <seealso cref="ServiceLifetime.Scoped"/> 262/// <seealso cref="ServiceLifetime.Scoped"/> 285/// <seealso cref="ServiceLifetime.Scoped"/> 308/// <seealso cref="ServiceLifetime.Singleton"/> 318return Add(services, serviceType, implementationType, ServiceLifetime.Singleton); 330/// <seealso cref="ServiceLifetime.Singleton"/> 340return Add(services, serviceType, implementationFactory, ServiceLifetime.Singleton); 352/// <seealso cref="ServiceLifetime.Singleton"/> 369/// <seealso cref="ServiceLifetime.Singleton"/> 387/// <seealso cref="ServiceLifetime.Singleton"/> 405/// <seealso cref="ServiceLifetime.Singleton"/> 428/// <seealso cref="ServiceLifetime.Singleton"/> 450/// <seealso cref="ServiceLifetime.Singleton"/> 473/// <seealso cref="ServiceLifetime.Singleton"/> 489ServiceLifetime lifetime) 500ServiceLifetime lifetime)
ServiceCollectionServiceExtensions.Keyed.cs (31)
24/// <seealso cref="ServiceLifetime.Transient"/> 35return AddKeyed(services, serviceType, serviceKey, implementationType, ServiceLifetime.Transient); 48/// <seealso cref="ServiceLifetime.Transient"/> 59return AddKeyed(services, serviceType, serviceKey, implementationFactory, ServiceLifetime.Transient); 72/// <seealso cref="ServiceLifetime.Transient"/> 92/// <seealso cref="ServiceLifetime.Transient"/> 112/// <seealso cref="ServiceLifetime.Transient"/> 133/// <seealso cref="ServiceLifetime.Transient"/> 158/// <seealso cref="ServiceLifetime.Transient"/> 182/// <seealso cref="ServiceLifetime.Scoped"/> 193return AddKeyed(services, serviceType, serviceKey, implementationType, ServiceLifetime.Scoped); 206/// <seealso cref="ServiceLifetime.Scoped"/> 217return AddKeyed(services, serviceType, serviceKey, implementationFactory, ServiceLifetime.Scoped); 230/// <seealso cref="ServiceLifetime.Scoped"/> 250/// <seealso cref="ServiceLifetime.Scoped"/> 270/// <seealso cref="ServiceLifetime.Scoped"/> 291/// <seealso cref="ServiceLifetime.Scoped"/> 316/// <seealso cref="ServiceLifetime.Scoped"/> 340/// <seealso cref="ServiceLifetime.Singleton"/> 351return AddKeyed(services, serviceType, serviceKey, implementationType, ServiceLifetime.Singleton); 364/// <seealso cref="ServiceLifetime.Singleton"/> 375return AddKeyed(services, serviceType, serviceKey, implementationFactory, ServiceLifetime.Singleton); 388/// <seealso cref="ServiceLifetime.Singleton"/> 408/// <seealso cref="ServiceLifetime.Singleton"/> 428/// <seealso cref="ServiceLifetime.Singleton"/> 449/// <seealso cref="ServiceLifetime.Singleton"/> 474/// <seealso cref="ServiceLifetime.Singleton"/> 498/// <seealso cref="ServiceLifetime.Singleton"/> 523/// <seealso cref="ServiceLifetime.Singleton"/> 541ServiceLifetime lifetime) 553ServiceLifetime lifetime)
ServiceDescriptor.cs (83)
21/// <param name="lifetime">The <see cref="ServiceLifetime"/> of the service.</param> 25ServiceLifetime lifetime) 36/// <param name="lifetime">The <see cref="ServiceLifetime"/> of the service.</param> 41ServiceLifetime lifetime) 52/// as a <see cref="ServiceLifetime.Singleton"/>. 65/// as a <see cref="ServiceLifetime.Singleton"/>. 74: this(serviceType, serviceKey, ServiceLifetime.Singleton) 87/// <param name="lifetime">The <see cref="ServiceLifetime"/> of the service.</param> 91ServiceLifetime lifetime) 106/// <param name="lifetime">The <see cref="ServiceLifetime"/> of the service.</param> 111ServiceLifetime lifetime) 129private ServiceDescriptor(Type serviceType, object? serviceKey, ServiceLifetime lifetime) 137/// Gets the <see cref="ServiceLifetime"/> of the service. 139public ServiceLifetime Lifetime { get; } 334/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 343return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Transient); 349/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 359return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Transient); 365/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 377return Describe(service, implementationType, ServiceLifetime.Transient); 383/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 397return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Transient); 404/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 417return Describe(typeof(TService), implementationFactory, ServiceLifetime.Transient); 424/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 439return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient); 445/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 455return Describe(typeof(TService), implementationFactory, ServiceLifetime.Transient); 461/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 472return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient); 478/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 488return Describe(service, implementationFactory, ServiceLifetime.Transient); 494/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 505return DescribeKeyed(service, serviceKey, implementationFactory, ServiceLifetime.Transient); 511/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 520return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Scoped); 526/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 536return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Scoped); 542/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 551return Describe(service, implementationType, ServiceLifetime.Scoped); 557/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 568return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Scoped); 575/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 588return Describe(typeof(TService), implementationFactory, ServiceLifetime.Scoped); 595/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 610return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped); 616/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 626return Describe(typeof(TService), implementationFactory, ServiceLifetime.Scoped); 632/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 643return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped); 649/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 659return Describe(service, implementationFactory, ServiceLifetime.Scoped); 665/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 676return DescribeKeyed(service, serviceKey, implementationFactory, ServiceLifetime.Scoped); 682/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 691return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Singleton); 697/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 708return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Singleton); 714/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 726return Describe(service, implementationType, ServiceLifetime.Singleton); 732/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 746return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Singleton); 753/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 766return Describe(typeof(TService), implementationFactory, ServiceLifetime.Singleton); 773/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 788return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton); 794/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 804return Describe(typeof(TService), implementationFactory, ServiceLifetime.Singleton); 810/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 823return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton); 829/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 841return Describe(serviceType, implementationFactory, ServiceLifetime.Singleton); 847/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 861return DescribeKeyed(serviceType, serviceKey, implementationFactory, ServiceLifetime.Singleton); 867/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 883/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 902/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 920/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 939ServiceLifetime lifetime) 962ServiceLifetime lifetime) 981ServiceLifetime lifetime) 995public static ServiceDescriptor Describe(Type serviceType, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime) 1010public static ServiceDescriptor DescribeKeyed(Type serviceType, object? serviceKey, Func<IServiceProvider, object?, object> implementationFactory, ServiceLifetime lifetime)
Microsoft.Extensions.Diagnostics.HealthChecks.Tests (5)
DependencyInjection\ServiceCollectionExtensionsTest.cs (5)
29Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); 37Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); 59Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); 67Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); 75Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime);
Microsoft.Extensions.Http (13)
DependencyInjection\HttpClientBuilderExtensions.cs (10)
652/// By default, the lifetime is <see cref="ServiceLifetime.Scoped"/>. 664/// WARNING: Registering the client as a keyed <see cref="ServiceLifetime.Transient"/> service will lead to the <see cref="HttpClient"/> and <see cref="HttpMessageHandler"/> 666/// <see cref="ServiceLifetime.Singleton"/> service. 669/// WARNING: In case of (1) a keyed <see cref="ServiceLifetime.Singleton"/> <see cref="HttpClient"/> registration, or (2) a keyed <see cref="ServiceLifetime.Transient"/> 670/// <see cref="HttpClient"/> injected into a <see cref="ServiceLifetime.Singleton"/> service, or (3) long-running application scopes, 672/// which can result in the loss of DNS changes. (This is a similar issue to the one with Typed Clients, that are registered as <see cref="ServiceLifetime.Transient"/> services.) 675/// If called twice with for a builder with the same name, the lifetime of the keyed service will be updated to the latest used <see cref="ServiceLifetime"/> value. 687public static IHttpClientBuilder AddAsKeyed(this IHttpClientBuilder builder, ServiceLifetime lifetime = ServiceLifetime.Scoped)
DependencyInjection\HttpClientKeyedLifetime.cs (3)
27private HttpClientKeyedLifetime(object serviceKey, ServiceLifetime lifetime) 35public HttpClientKeyedLifetime(ServiceLifetime lifetime) : this(KeyedService.AnyKey, lifetime) { } 36public HttpClientKeyedLifetime(string name, ServiceLifetime lifetime) : this((object)name, lifetime) { }