486 references to ServiceLifetime
Aspire.Azure.AI.Inference.Tests (2)
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.Files.DataLake.Tests (2)
Aspire.Azure.Storage.Queues.Tests (2)
Aspire.Components.Common.TestUtilities (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.v2.Tests (2)
Aspire.MongoDB.EntityFrameworkCore.Tests (3)
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.v6.Tests (2)
Aspire.StackExchange.Redis.Tests (2)
Microsoft.AspNetCore.AsyncState.Tests (2)
Microsoft.AspNetCore.Components.WebView.Test (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)
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)
Microsoft.Extensions.AI (48)
Microsoft.Extensions.AI.Tests (64)
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)
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)
Microsoft.Extensions.Http (13)
Microsoft.Maui (2)