486 references to ServiceLifetime
Aspire.Azure.AI.Inference.Tests (2)
ConformanceTests.cs (2)
17protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.AI.OpenAI.Tests (2)
ConformanceTests.cs (2)
18protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Data.Tables.Tests (2)
ConformanceTests.cs (2)
22protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Messaging.EventHubs.Tests (2)
ConformanceTestsBase.cs (2)
21protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Messaging.ServiceBus.Tests (2)
ConformanceTests.cs (2)
25protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Messaging.WebPubSub.Tests (2)
ConformanceTests.cs (2)
20protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (4)
ConformanceTests.cs (2)
20protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichNpgsqlTests.cs (2)
262}, contextLifetime: ServiceLifetime.Singleton); 268Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Azure.Npgsql.Tests (2)
ConformanceTests.cs (2)
19protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Search.Documents.Tests (2)
ConformanceTests.cs (2)
18protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Security.KeyVault.Tests (6)
CertificateClientConformanceTests.cs (2)
21protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
KeyClientConformanceTests.cs (2)
23protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
SecretClientConformanceTests.cs (2)
22protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Storage.Blobs.Tests (2)
ConformanceTests.cs (2)
22protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Storage.Files.DataLake.Tests (2)
ConformanceTests.cs (2)
21protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Azure.Storage.Queues.Tests (2)
ConformanceTests.cs (2)
22protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Components.Common.TestUtilities (4)
ConformanceTests.cs (4)
45protected abstract ServiceLifetime ServiceLifetime { get; } 231case ServiceLifetime.Singleton: 235case ServiceLifetime.Scoped: 239case 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.Hosting.Testing.Tests (1)
ResourceLoggerForwarderServiceTests.cs (1)
25&& 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)
19protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Scoped;
Aspire.Microsoft.EntityFrameworkCore.Cosmos.Tests (4)
ConformanceTests.cs (2)
16protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichCosmosDbTests.cs (2)
108}, contextLifetime: ServiceLifetime.Singleton); 114Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Microsoft.EntityFrameworkCore.SqlServer.Tests (4)
ConformanceTests.cs (2)
21protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichSqlServerTests.cs (2)
249}, contextLifetime: ServiceLifetime.Singleton); 255Assert.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.MongoDB.Driver.v2.Tests (2)
tests\Aspire.MongoDB.Driver.Tests\ConformanceTests.cs (2)
18protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.MongoDB.EntityFrameworkCore.Tests (3)
ConformanceTests.cs (1)
21protected override ServiceLifetime ServiceLifetime { get; }
EnrichMongoDbTests.cs (2)
77}, contextLifetime: ServiceLifetime.Singleton); 83Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.MySqlConnector.Tests (2)
ConformanceTests.cs (2)
19protected 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)
20protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichNpgsqlTests.cs (2)
261}, contextLifetime: ServiceLifetime.Singleton); 267Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Npgsql.Tests (2)
ConformanceTests.cs (2)
19protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.OpenAI.Tests (2)
ConformanceTests.cs (2)
17protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.Oracle.EntityFrameworkCore.Tests (4)
ConformanceTests.cs (2)
25protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichOracleDatabaseTests.cs (2)
249}, contextLifetime: ServiceLifetime.Singleton); 255Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Pomelo.EntityFrameworkCore.MySql.Tests (4)
ConformanceTests.cs (2)
22protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
EnrichMySqlTests.cs (2)
265}, contextLifetime: ServiceLifetime.Singleton); 271Assert.Equal(ServiceLifetime.Singleton, optionsDescriptor.Lifetime);
Aspire.Qdrant.Client.Tests (2)
ConformanceTests.cs (2)
26protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.RabbitMQ.Client.Tests (2)
ConformanceTests.cs (2)
23protected override ServiceLifetime ServiceLifetime => ServiceLifetime.Singleton;
Aspire.RabbitMQ.Client.v6.Tests (2)
tests\Aspire.RabbitMQ.Client.Tests\ConformanceTests.cs (2)
23protected 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.Components.WebView.Test (2)
ComponentsWebViewServiceCollectionExtensionsTests.cs (2)
46Assert.Equal(ServiceLifetime.Scoped, persistenceManagerDescriptor.Lifetime); 47Assert.Equal(ServiceLifetime.Scoped, persistentStateDescriptor.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)
40Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 41Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 42Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 74Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 75Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 76Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 107Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 108Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 109Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 140Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 141Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 142Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 162Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 163Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 164Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 186Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 187Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 188Assert.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.AI (48)
ChatCompletion\ChatClientBuilderServiceCollectionExtensions.cs (12)
16/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 24ServiceLifetime lifetime = ServiceLifetime.Singleton) 35/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 43ServiceLifetime lifetime = ServiceLifetime.Singleton) 57/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 66ServiceLifetime lifetime = ServiceLifetime.Singleton) 78/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 87ServiceLifetime lifetime = ServiceLifetime.Singleton)
Embeddings\EmbeddingGeneratorBuilderServiceCollectionExtensions.cs (12)
18/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 26ServiceLifetime lifetime = ServiceLifetime.Singleton) 40/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 48ServiceLifetime lifetime = ServiceLifetime.Singleton) 67/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 76ServiceLifetime lifetime = ServiceLifetime.Singleton) 91/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 100ServiceLifetime lifetime = ServiceLifetime.Singleton)
Image\ImageGeneratorBuilderServiceCollectionExtensions.cs (12)
19/// <param name="lifetime">The service lifetime for the generator. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 26ServiceLifetime lifetime = ServiceLifetime.Singleton) 32/// <param name="lifetime">The service lifetime for the generator. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 39ServiceLifetime lifetime = ServiceLifetime.Singleton) 53/// <param name="lifetime">The service lifetime for the generator. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 61ServiceLifetime lifetime = ServiceLifetime.Singleton) 68/// <param name="lifetime">The service lifetime for the generator. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 76ServiceLifetime lifetime = ServiceLifetime.Singleton)
SpeechToText\SpeechToTextClientBuilderServiceCollectionExtensions.cs (12)
19/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 25ServiceLifetime lifetime = ServiceLifetime.Singleton) 31/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 37ServiceLifetime lifetime = ServiceLifetime.Singleton) 51/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 58ServiceLifetime lifetime = ServiceLifetime.Singleton) 65/// <param name="lifetime">The service lifetime for the client. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param> 72ServiceLifetime lifetime = ServiceLifetime.Singleton)
Microsoft.Extensions.AI.Tests (64)
ChatCompletion\DependencyInjectionPatterns.cs (38)
114[InlineData(ServiceLifetime.Singleton)] 115[InlineData(ServiceLifetime.Scoped)] 116[InlineData(ServiceLifetime.Transient)] 117public void AddChatClient_RegistersExpectedLifetime(ServiceLifetime? lifetime) 120ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 136[InlineData(ServiceLifetime.Singleton)] 137[InlineData(ServiceLifetime.Scoped)] 138[InlineData(ServiceLifetime.Transient)] 139public void AddKeyedChatClient_RegistersExpectedLifetime(ServiceLifetime? lifetime) 142ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 159[InlineData(ServiceLifetime.Singleton)] 160[InlineData(ServiceLifetime.Scoped)] 161[InlineData(ServiceLifetime.Transient)] 162public void AddEmbeddingGenerator_RegistersExpectedLifetime(ServiceLifetime? lifetime) 165ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 182[InlineData(ServiceLifetime.Singleton)] 183[InlineData(ServiceLifetime.Scoped)] 184[InlineData(ServiceLifetime.Transient)] 185public void AddEmbeddingGenerator_RegistersNonGeneric(ServiceLifetime? lifetime) 188ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 199Assert.Equal(lifetime != ServiceLifetime.Transient, ReferenceEquals(g, ng)); 204[InlineData(ServiceLifetime.Singleton)] 205[InlineData(ServiceLifetime.Scoped)] 206[InlineData(ServiceLifetime.Transient)] 207public void AddKeyedEmbeddingGenerator_RegistersExpectedLifetime(ServiceLifetime? lifetime) 210ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 228[InlineData(ServiceLifetime.Singleton)] 229[InlineData(ServiceLifetime.Scoped)] 230[InlineData(ServiceLifetime.Transient)] 231public void AddKeyedEmbeddingGenerator_RegistersNonGeneric(ServiceLifetime? lifetime) 234ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 245Assert.Equal(lifetime != ServiceLifetime.Transient, ReferenceEquals(g, ng));
Image\ImageGeneratorDependencyInjectionPatterns.cs (13)
114[InlineData(ServiceLifetime.Singleton)] 115[InlineData(ServiceLifetime.Scoped)] 116[InlineData(ServiceLifetime.Transient)] 117public void AddImageGenerator_RegistersExpectedLifetime(ServiceLifetime? lifetime) 120ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 136[InlineData(ServiceLifetime.Singleton)] 137[InlineData(ServiceLifetime.Scoped)] 138[InlineData(ServiceLifetime.Transient)] 139public void AddKeyedImageGenerator_RegistersExpectedLifetime(ServiceLifetime? lifetime) 142ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 170Assert.Equal(ServiceLifetime.Singleton, sd.Lifetime);
SpeechToText\SpeechToTextClientDependencyInjectionPatterns.cs (13)
114[InlineData(ServiceLifetime.Singleton)] 115[InlineData(ServiceLifetime.Scoped)] 116[InlineData(ServiceLifetime.Transient)] 117public void AddSpeechToTextClient_RegistersExpectedLifetime(ServiceLifetime? lifetime) 120ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 136[InlineData(ServiceLifetime.Singleton)] 137[InlineData(ServiceLifetime.Scoped)] 138[InlineData(ServiceLifetime.Transient)] 139public void AddKeyedSpeechToTextClient_RegistersExpectedLifetime(ServiceLifetime? lifetime) 142ServiceLifetime expectedLifetime = lifetime ?? ServiceLifetime.Singleton; 170Assert.Equal(ServiceLifetime.Singleton, sd.Lifetime);
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)
37Assert.Equal(ServiceLifetime.Singleton, distributedCache.Lifetime); 56Assert.Equal(ServiceLifetime.Scoped, distributedCache.Lifetime); 127Assert.Equal(ServiceLifetime.Scoped, distributedCache.Lifetime);
Microsoft.Extensions.DependencyInjection (11)
DependencyInjectionEventSource.cs (3)
219case ServiceLifetime.Singleton: 222case ServiceLifetime.Scoped: 225case 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 118/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 140/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 162/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 177/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 195/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 212/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 230/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 252/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 274/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 289/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 307/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 324/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 342/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 364/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 386/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 401/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 419/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 438/// 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 33/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 57/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Transient"/> service 81/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 97/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 116/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Transient"/> service 135/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 155/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 179/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Scoped"/> service 203/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 219/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 238/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Scoped"/> service 257/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 277/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 301/// Adds the specified <paramref name="service"/> as a <see cref="ServiceLifetime.Singleton"/> service 325/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 341/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 360/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service 380/// Adds the specified <typeparamref name="TService"/> as a <see cref="ServiceLifetime.Singleton"/> service
ServiceCollectionServiceExtensions.cs (31)
28/// <seealso cref="ServiceLifetime.Transient"/> 38return Add(services, serviceType, implementationType, ServiceLifetime.Transient); 55/// <seealso cref="ServiceLifetime.Transient"/> 65return Add(services, serviceType, implementationFactory, ServiceLifetime.Transient); 82/// <seealso cref="ServiceLifetime.Transient"/> 104/// <seealso cref="ServiceLifetime.Transient"/> 127/// <seealso cref="ServiceLifetime.Transient"/> 150/// <seealso cref="ServiceLifetime.Transient"/> 178/// <seealso cref="ServiceLifetime.Transient"/> 205/// <seealso cref="ServiceLifetime.Scoped"/> 215return Add(services, serviceType, implementationType, ServiceLifetime.Scoped); 232/// <seealso cref="ServiceLifetime.Scoped"/> 242return Add(services, serviceType, implementationFactory, ServiceLifetime.Scoped); 259/// <seealso cref="ServiceLifetime.Scoped"/> 281/// <seealso cref="ServiceLifetime.Scoped"/> 304/// <seealso cref="ServiceLifetime.Scoped"/> 327/// <seealso cref="ServiceLifetime.Scoped"/> 355/// <seealso cref="ServiceLifetime.Scoped"/> 383/// <seealso cref="ServiceLifetime.Singleton"/> 393return Add(services, serviceType, implementationType, ServiceLifetime.Singleton); 410/// <seealso cref="ServiceLifetime.Singleton"/> 420return Add(services, serviceType, implementationFactory, ServiceLifetime.Singleton); 437/// <seealso cref="ServiceLifetime.Singleton"/> 459/// <seealso cref="ServiceLifetime.Singleton"/> 482/// <seealso cref="ServiceLifetime.Singleton"/> 505/// <seealso cref="ServiceLifetime.Singleton"/> 533/// <seealso cref="ServiceLifetime.Singleton"/> 560/// <seealso cref="ServiceLifetime.Singleton"/> 588/// <seealso cref="ServiceLifetime.Singleton"/> 604ServiceLifetime lifetime) 615ServiceLifetime lifetime)
ServiceCollectionServiceExtensions.Keyed.cs (31)
29/// <seealso cref="ServiceLifetime.Transient"/> 40return AddKeyed(services, serviceType, serviceKey, implementationType, ServiceLifetime.Transient); 58/// <seealso cref="ServiceLifetime.Transient"/> 69return AddKeyed(services, serviceType, serviceKey, implementationFactory, ServiceLifetime.Transient); 87/// <seealso cref="ServiceLifetime.Transient"/> 112/// <seealso cref="ServiceLifetime.Transient"/> 137/// <seealso cref="ServiceLifetime.Transient"/> 163/// <seealso cref="ServiceLifetime.Transient"/> 193/// <seealso cref="ServiceLifetime.Transient"/> 222/// <seealso cref="ServiceLifetime.Scoped"/> 233return AddKeyed(services, serviceType, serviceKey, implementationType, ServiceLifetime.Scoped); 251/// <seealso cref="ServiceLifetime.Scoped"/> 262return AddKeyed(services, serviceType, serviceKey, implementationFactory, ServiceLifetime.Scoped); 280/// <seealso cref="ServiceLifetime.Scoped"/> 305/// <seealso cref="ServiceLifetime.Scoped"/> 330/// <seealso cref="ServiceLifetime.Scoped"/> 356/// <seealso cref="ServiceLifetime.Scoped"/> 386/// <seealso cref="ServiceLifetime.Scoped"/> 415/// <seealso cref="ServiceLifetime.Singleton"/> 426return AddKeyed(services, serviceType, serviceKey, implementationType, ServiceLifetime.Singleton); 444/// <seealso cref="ServiceLifetime.Singleton"/> 455return AddKeyed(services, serviceType, serviceKey, implementationFactory, ServiceLifetime.Singleton); 473/// <seealso cref="ServiceLifetime.Singleton"/> 498/// <seealso cref="ServiceLifetime.Singleton"/> 523/// <seealso cref="ServiceLifetime.Singleton"/> 549/// <seealso cref="ServiceLifetime.Singleton"/> 579/// <seealso cref="ServiceLifetime.Singleton"/> 608/// <seealso cref="ServiceLifetime.Singleton"/> 638/// <seealso cref="ServiceLifetime.Singleton"/> 656ServiceLifetime lifetime) 668ServiceLifetime lifetime)
ServiceDescriptor.cs (83)
22/// <param name="lifetime">The <see cref="ServiceLifetime"/> of the service.</param> 26ServiceLifetime lifetime) 37/// <param name="lifetime">The <see cref="ServiceLifetime"/> of the service.</param> 42ServiceLifetime lifetime) 53/// as a <see cref="ServiceLifetime.Singleton"/>. 66/// as a <see cref="ServiceLifetime.Singleton"/>. 75: this(serviceType, serviceKey, ServiceLifetime.Singleton) 88/// <param name="lifetime">The <see cref="ServiceLifetime"/> of the service.</param> 92ServiceLifetime lifetime) 107/// <param name="lifetime">The <see cref="ServiceLifetime"/> of the service.</param> 112ServiceLifetime lifetime) 130private ServiceDescriptor(Type serviceType, object? serviceKey, ServiceLifetime lifetime) 138/// Gets the <see cref="ServiceLifetime"/> of the service. 140public ServiceLifetime Lifetime { get; } 356/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 365return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Transient); 371/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 381return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Transient); 387/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 399return Describe(service, implementationType, ServiceLifetime.Transient); 405/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 419return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Transient); 426/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 439return Describe(typeof(TService), implementationFactory, ServiceLifetime.Transient); 446/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 461return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient); 467/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 477return Describe(typeof(TService), implementationFactory, ServiceLifetime.Transient); 483/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 494return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient); 500/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 510return Describe(service, implementationFactory, ServiceLifetime.Transient); 516/// and the <see cref="ServiceLifetime.Transient"/> lifetime. 527return DescribeKeyed(service, serviceKey, implementationFactory, ServiceLifetime.Transient); 533/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 542return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Scoped); 548/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 558return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Scoped); 564/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 573return Describe(service, implementationType, ServiceLifetime.Scoped); 579/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 590return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Scoped); 597/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 610return Describe(typeof(TService), implementationFactory, ServiceLifetime.Scoped); 617/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 632return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped); 638/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 648return Describe(typeof(TService), implementationFactory, ServiceLifetime.Scoped); 654/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 665return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped); 671/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 681return Describe(service, implementationFactory, ServiceLifetime.Scoped); 687/// and the <see cref="ServiceLifetime.Scoped"/> lifetime. 698return DescribeKeyed(service, serviceKey, implementationFactory, ServiceLifetime.Scoped); 704/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 713return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Singleton); 719/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 730return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Singleton); 736/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 748return Describe(service, implementationType, ServiceLifetime.Singleton); 754/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 768return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Singleton); 775/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 788return Describe(typeof(TService), implementationFactory, ServiceLifetime.Singleton); 795/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 810return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton); 816/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 826return Describe(typeof(TService), implementationFactory, ServiceLifetime.Singleton); 832/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 845return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton); 851/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 863return Describe(serviceType, implementationFactory, ServiceLifetime.Singleton); 869/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 883return DescribeKeyed(serviceType, serviceKey, implementationFactory, ServiceLifetime.Singleton); 889/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 905/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 924/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 942/// and the <see cref="ServiceLifetime.Singleton"/> lifetime. 961ServiceLifetime lifetime) 984ServiceLifetime lifetime) 1003ServiceLifetime lifetime) 1017public static ServiceDescriptor Describe(Type serviceType, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime) 1032public 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) { }
Microsoft.Maui (2)
Hosting\Internal\MauiFactory.cs (2)
36 if (descriptor.Lifetime == ServiceLifetime.Singleton) 43 if (descriptor.Lifetime == ServiceLifetime.Singleton)