349 references to ServiceLifetime
Aspire.Azure.AI.OpenAI.Tests (2)
Aspire.Azure.Data.Tables.Tests (2)
Aspire.Azure.Messaging.ServiceBus.Tests (2)
Aspire.Azure.Messaging.WebPubSub.Tests (2)
Aspire.Azure.Search.Documents.Tests (2)
Aspire.Azure.Security.KeyVault.Tests (2)
Aspire.Azure.Storage.Blobs.Tests (2)
Aspire.Azure.Storage.Queues.Tests (2)
Aspire.Components.Common.Tests (4)
Aspire.Confluent.Kafka.Tests (4)
Aspire.Elastic.Clients.Elasticsearch.Tests (2)
Aspire.Hosting.Testing.Tests (1)
Aspire.Microsoft.Azure.Cosmos.Tests (2)
Aspire.Microsoft.Data.SqlClient.Tests (2)
Aspire.Microsoft.EntityFrameworkCore.Cosmos.Tests (4)
Aspire.Microsoft.EntityFrameworkCore.SqlServer.Tests (4)
Aspire.Milvus.Client.Tests (2)
Aspire.MongoDB.Driver.Tests (2)
Aspire.MySqlConnector.Tests (2)
Aspire.NATS.Net.Tests (2)
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (4)
Aspire.Npgsql.Tests (2)
Aspire.OpenAI.Tests (2)
Aspire.Oracle.EntityFrameworkCore.Tests (4)
Aspire.Pomelo.EntityFrameworkCore.MySql.Tests (4)
Aspire.Qdrant.Client.Tests (2)
Aspire.RabbitMQ.Client.Tests (2)
Aspire.StackExchange.Redis.Tests (2)
Microsoft.AspNetCore.AsyncState.Tests (2)
Microsoft.AspNetCore.DataProtection (2)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (1)
Microsoft.AspNetCore.Http.Tests (1)
Microsoft.AspNetCore.Identity.FunctionalTests (1)
Microsoft.AspNetCore.Mvc.Core.Test (3)
Microsoft.AspNetCore.Mvc.Localization.Test (14)
Microsoft.AspNetCore.Mvc.Razor.Test (6)
Microsoft.AspNetCore.Mvc.Test (3)
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (3)
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)
Microsoft.Extensions.AsyncState.Tests (3)
Microsoft.Extensions.Caching.SqlServer.Tests (2)
Microsoft.Extensions.Caching.StackExchangeRedis.Tests (3)
Microsoft.Extensions.DependencyInjection (11)
Microsoft.Extensions.DependencyInjection.Abstractions (183)
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)
Microsoft.Extensions.Http (13)