ServiceCollectionServiceExtensions Class

Extension methods for adding services to an Microsoft.Extensions.DependencyInjection.IServiceCollection.

Namespace
Microsoft.Extensions.DependencyInjection
Assemblies
  • Microsoft.Extensions.DependencyInjection.Abstractions

Syntax

public class ServiceCollectionServiceExtensions
class Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions

Methods

AddScoped(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type)

Adds a scoped service of the type specified in <em>serviceType</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddScoped(this IServiceCollection services, Type serviceType)
AddScoped(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type, System.Func<System.IServiceProvider, System.Object>)

Adds a scoped service of the type specified in <em>serviceType</em> with a factory specified in <em>implementationFactory</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddScoped(this IServiceCollection services, Type serviceType, Func<IServiceProvider, object> implementationFactory)
AddScoped(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type, System.Type)

Adds a scoped service of the type specified in <em>serviceType</em> with an implementation of the type specified in <em>implementationType</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddScoped(this IServiceCollection services, Type serviceType, Type implementationType)
AddScoped<TService>(Microsoft.Extensions.DependencyInjection.IServiceCollection)

Adds a scoped service of the type specified in <em>TService</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:services (Microsoft.Extensions.DependencyInjection.IServiceCollection) – The Microsoft.Extensions.DependencyInjection.IServiceCollection to add the service to.
Return type:Microsoft.Extensions.DependencyInjection.IServiceCollection
Returns:A reference to this instance after the operation has completed.
public static IServiceCollection AddScoped<TService>(this IServiceCollection services)where TService : class
AddScoped<TService>(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Func<System.IServiceProvider, TService>)

Adds a scoped service of the type specified in <em>TService</em> with a factory specified in <em>implementationFactory</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddScoped<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)where TService : class
AddScoped<TService, TImplementation>(Microsoft.Extensions.DependencyInjection.IServiceCollection)

Adds a scoped service of the type specified in <em>TService</em> with an implementation type specified in <em>TImplementation</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:services (Microsoft.Extensions.DependencyInjection.IServiceCollection) – The Microsoft.Extensions.DependencyInjection.IServiceCollection to add the service to.
Return type:Microsoft.Extensions.DependencyInjection.IServiceCollection
Returns:A reference to this instance after the operation has completed.
public static IServiceCollection AddScoped<TService, TImplementation>(this IServiceCollection services)where TService : class where TImplementation : class, TService
AddScoped<TService, TImplementation>(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Func<System.IServiceProvider, TImplementation>)

Adds a scoped service of the type specified in <em>TService</em> with an implementation type specified in <em>TImplementation</em> using the factory specified in <em>implementationFactory</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddScoped<TService, TImplementation>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory)where TService : class where TImplementation : class, TService
AddSingleton(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type)

Adds a singleton service of the type specified in <em>serviceType</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddSingleton(this IServiceCollection services, Type serviceType)
AddSingleton(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type, System.Func<System.IServiceProvider, System.Object>)

Adds a singleton service of the type specified in <em>serviceType</em> with a factory specified in <em>implementationFactory</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddSingleton(this IServiceCollection services, Type serviceType, Func<IServiceProvider, object> implementationFactory)
AddSingleton(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type, System.Object)

Adds a singleton service of the type specified in <em>serviceType</em> with an instance specified in <em>implementationInstance</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddSingleton(this IServiceCollection services, Type serviceType, object implementationInstance)
AddSingleton(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type, System.Type)

Adds a singleton service of the type specified in <em>serviceType</em> with an implementation of the type specified in <em>implementationType</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddSingleton(this IServiceCollection services, Type serviceType, Type implementationType)
AddSingleton<TService>(Microsoft.Extensions.DependencyInjection.IServiceCollection)

Adds a singleton service of the type specified in <em>TService</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:services (Microsoft.Extensions.DependencyInjection.IServiceCollection) – The Microsoft.Extensions.DependencyInjection.IServiceCollection to add the service to.
Return type:Microsoft.Extensions.DependencyInjection.IServiceCollection
Returns:A reference to this instance after the operation has completed.
public static IServiceCollection AddSingleton<TService>(this IServiceCollection services)where TService : class
AddSingleton<TService>(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Func<System.IServiceProvider, TService>)

Adds a singleton service of the type specified in <em>TService</em> with a factory specified in <em>implementationFactory</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddSingleton<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)where TService : class
AddSingleton<TService>(Microsoft.Extensions.DependencyInjection.IServiceCollection, TService)

Adds a singleton service of the type specified in <em>TService</em> with an instance specified in <em>implementationInstance</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddSingleton<TService>(this IServiceCollection services, TService implementationInstance)where TService : class
AddSingleton<TService, TImplementation>(Microsoft.Extensions.DependencyInjection.IServiceCollection)

Adds a singleton service of the type specified in <em>TService</em> with an implementation type specified in <em>TImplementation</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:services (Microsoft.Extensions.DependencyInjection.IServiceCollection) – The Microsoft.Extensions.DependencyInjection.IServiceCollection to add the service to.
Return type:Microsoft.Extensions.DependencyInjection.IServiceCollection
Returns:A reference to this instance after the operation has completed.
public static IServiceCollection AddSingleton<TService, TImplementation>(this IServiceCollection services)where TService : class where TImplementation : class, TService
AddSingleton<TService, TImplementation>(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Func<System.IServiceProvider, TImplementation>)

Adds a singleton service of the type specified in <em>TService</em> with an implementation type specified in <em>TImplementation</em> using the factory specified in <em>implementationFactory</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddSingleton<TService, TImplementation>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory)where TService : class where TImplementation : class, TService
AddTransient(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type)

Adds a transient service of the type specified in <em>serviceType</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddTransient(this IServiceCollection services, Type serviceType)
AddTransient(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type, System.Func<System.IServiceProvider, System.Object>)

Adds a transient service of the type specified in <em>serviceType</em> with a factory specified in <em>implementationFactory</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddTransient(this IServiceCollection services, Type serviceType, Func<IServiceProvider, object> implementationFactory)
AddTransient(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Type, System.Type)

Adds a transient service of the type specified in <em>serviceType</em> with an implementation of the type specified in <em>implementationType</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddTransient(this IServiceCollection services, Type serviceType, Type implementationType)
AddTransient<TService>(Microsoft.Extensions.DependencyInjection.IServiceCollection)

Adds a transient service of the type specified in <em>TService</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:services (Microsoft.Extensions.DependencyInjection.IServiceCollection) – The Microsoft.Extensions.DependencyInjection.IServiceCollection to add the service to.
Return type:Microsoft.Extensions.DependencyInjection.IServiceCollection
Returns:A reference to this instance after the operation has completed.
public static IServiceCollection AddTransient<TService>(this IServiceCollection services)where TService : class
AddTransient<TService>(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Func<System.IServiceProvider, TService>)

Adds a transient service of the type specified in <em>TService</em> with a factory specified in <em>implementationFactory</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddTransient<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)where TService : class
AddTransient<TService, TImplementation>(Microsoft.Extensions.DependencyInjection.IServiceCollection)

Adds a transient service of the type specified in <em>TService</em> with an implementation type specified in <em>TImplementation</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:services (Microsoft.Extensions.DependencyInjection.IServiceCollection) – The Microsoft.Extensions.DependencyInjection.IServiceCollection to add the service to.
Return type:Microsoft.Extensions.DependencyInjection.IServiceCollection
Returns:A reference to this instance after the operation has completed.
public static IServiceCollection AddTransient<TService, TImplementation>(this IServiceCollection services)where TService : class where TImplementation : class, TService
AddTransient<TService, TImplementation>(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Func<System.IServiceProvider, TImplementation>)

Adds a transient service of the type specified in <em>TService</em> with an implementation type specified in <em>TImplementation</em> using the factory specified in <em>implementationFactory</em> to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

A reference to this instance after the operation has completed.

public static IServiceCollection AddTransient<TService, TImplementation>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory)where TService : class where TImplementation : class, TService