451 references to ServiceLifetime
Aspire.Azure.AI.OpenAI.Tests (2)
Aspire.Azure.Data.Tables.Tests (2)
Aspire.Azure.Messaging.EventHubs.Tests (2)
Aspire.Azure.Messaging.ServiceBus.Tests (2)
Aspire.Azure.Messaging.WebPubSub.Tests (2)
Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (4)
Aspire.Azure.Npgsql.Tests (2)
Aspire.Azure.Search.Documents.Tests (2)
Aspire.Azure.Security.KeyVault.Tests (6)
Aspire.Azure.Storage.Blobs.Tests (2)
Aspire.Azure.Storage.Queues.Tests (2)
Aspire.Components.Common.Tests (4)
Aspire.Confluent.Kafka.Tests (4)
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.MongoDB.Driver.v3.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.RabbitMQ.Client.v7.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)
41Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
42Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
43Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton);
75Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
76Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
77Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton);
108Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
109Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
110Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton);
141Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
142Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
143Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton);
163Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
164Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
165Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton);
187Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
188Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName);
189Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton);
Microsoft.DotNet.Internal.DependencyInjection.Testing (6)
Microsoft.Extensions.AI (36)
Microsoft.Extensions.AI.Tests (50)
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)
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; }
355/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
364return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Transient);
370/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
380return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Transient);
386/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
398return Describe(service, implementationType, ServiceLifetime.Transient);
404/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
418return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Transient);
425/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
438return Describe(typeof(TService), implementationFactory, ServiceLifetime.Transient);
445/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
460return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient);
466/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
476return Describe(typeof(TService), implementationFactory, ServiceLifetime.Transient);
482/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
493return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient);
499/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
509return Describe(service, implementationFactory, ServiceLifetime.Transient);
515/// and the <see cref="ServiceLifetime.Transient"/> lifetime.
526return DescribeKeyed(service, serviceKey, implementationFactory, ServiceLifetime.Transient);
532/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
541return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Scoped);
547/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
557return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Scoped);
563/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
572return Describe(service, implementationType, ServiceLifetime.Scoped);
578/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
589return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Scoped);
596/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
609return Describe(typeof(TService), implementationFactory, ServiceLifetime.Scoped);
616/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
631return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped);
637/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
647return Describe(typeof(TService), implementationFactory, ServiceLifetime.Scoped);
653/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
664return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped);
670/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
680return Describe(service, implementationFactory, ServiceLifetime.Scoped);
686/// and the <see cref="ServiceLifetime.Scoped"/> lifetime.
697return DescribeKeyed(service, serviceKey, implementationFactory, ServiceLifetime.Scoped);
703/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
712return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Singleton);
718/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
729return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Singleton);
735/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
747return Describe(service, implementationType, ServiceLifetime.Singleton);
753/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
767return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Singleton);
774/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
787return Describe(typeof(TService), implementationFactory, ServiceLifetime.Singleton);
794/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
809return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton);
815/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
825return Describe(typeof(TService), implementationFactory, ServiceLifetime.Singleton);
831/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
844return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton);
850/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
862return Describe(serviceType, implementationFactory, ServiceLifetime.Singleton);
868/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
882return DescribeKeyed(serviceType, serviceKey, implementationFactory, ServiceLifetime.Singleton);
888/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
904/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
923/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
941/// and the <see cref="ServiceLifetime.Singleton"/> lifetime.
960ServiceLifetime lifetime)
983ServiceLifetime lifetime)
1002ServiceLifetime lifetime)
1016public static ServiceDescriptor Describe(Type serviceType, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime)
1031public static ServiceDescriptor DescribeKeyed(Type serviceType, object? serviceKey, Func<IServiceProvider, object?, object> implementationFactory, ServiceLifetime lifetime)
Microsoft.Extensions.Diagnostics.HealthChecks.Tests (5)
Microsoft.Extensions.Http (13)
Microsoft.Maui (2)