ServiceCollectionServiceExtensions.AddScoped 方法

定义

重载

AddScoped(IServiceCollection, Type)

serviceType 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。

AddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>)

使用 implementationFactory 中指定的中心将 serviceType 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。

AddScoped(IServiceCollection, Type, Type)

serviceType 中指定类型的范围内的服务和 implementationType 中指定类型的实现添加到指定的 IServiceCollection 中。

AddScoped<TService,TImplementation>(IServiceCollection)

TService 中指定类型的范围内的服务和 TImplementation 中指定类型的实现添加到指定的 IServiceCollection 中。

AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

使用 implementationFactory 中指定的中心将 TService 中指定类型的范围内的服务和 TImplementation 中指定类型的实现添加到指定的 IServiceCollection 中。

AddScoped<TService>(IServiceCollection)

TService 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。

AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>)

使用 implementationFactory 中指定的中心将 TService 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。

AddScoped(IServiceCollection, Type)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

serviceType 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType);
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddScoped (services As IServiceCollection, serviceType As Type) As IServiceCollection

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollection

serviceType
Type

要注册的服务类型和要使用的实现。

返回

完成操作后对此实例的引用。

另请参阅

适用于

AddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

使用 implementationFactory 中指定的中心将 serviceType 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, Func<IServiceProvider ^, System::Object ^> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, Func<IServiceProvider,object> implementationFactory);
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Func<IServiceProvider, obj> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddScoped (services As IServiceCollection, serviceType As Type, implementationFactory As Func(Of IServiceProvider, Object)) As IServiceCollection

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollection

serviceType
Type

要注册的服务类型。

implementationFactory
Func<IServiceProvider,Object>

用于创建服务的工厂。

返回

完成操作后对此实例的引用。

另请参阅

适用于

AddScoped(IServiceCollection, Type, Type)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

serviceType 中指定类型的范围内的服务和 implementationType 中指定类型的实现添加到指定的 IServiceCollection 中。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, Type ^ implementationType);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, Type implementationType);
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Type -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddScoped (services As IServiceCollection, serviceType As Type, implementationType As Type) As IServiceCollection

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollection

serviceType
Type

要注册的服务类型。

implementationType
Type

服务的实现类型。

返回

完成操作后对此实例的引用。

另请参阅

适用于

AddScoped<TService,TImplementation>(IServiceCollection)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

TService 中指定类型的范围内的服务和 TImplementation 中指定类型的实现添加到指定的 IServiceCollection 中。

public:
generic <typename TService, typename TImplementation>
 where TService : class where TImplementation : class, TService[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TService : class where TImplementation : class, TService;
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddScoped(Of TService As Class, TImplementation As Class) (services As IServiceCollection) As IServiceCollection

类型参数

TService

要添加的服务类型。

TImplementation

要使用的实现的类型。

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollection

返回

完成操作后对此实例的引用。

另请参阅

适用于

AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

使用 implementationFactory 中指定的中心将 TService 中指定类型的范围内的服务和 TImplementation 中指定类型的实现添加到指定的 IServiceCollection 中。

public:
generic <typename TService, typename TImplementation>
 where TService : class where TImplementation : class, TService[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Func<IServiceProvider ^, TImplementation> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<IServiceProvider,TImplementation> implementationFactory) where TService : class where TImplementation : class, TService;
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, #'Service> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddScoped(Of TService As Class, TImplementation As Class) (services As IServiceCollection, implementationFactory As Func(Of IServiceProvider, TImplementation)) As IServiceCollection

类型参数

TService

要添加的服务类型。

TImplementation

要使用的实现的类型。

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollection

implementationFactory
Func<IServiceProvider,TImplementation>

用于创建服务的工厂。

返回

完成操作后对此实例的引用。

另请参阅

适用于

AddScoped<TService>(IServiceCollection)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

TService 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TService : class;
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddScoped(Of TService As Class) (services As IServiceCollection) As IServiceCollection

类型参数

TService

要添加的服务类型。

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollection

返回

完成操作后对此实例的引用。

另请参阅

适用于

AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

使用 implementationFactory 中指定的中心将 TService 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Func<IServiceProvider ^, TService> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<IServiceProvider,TService> implementationFactory) where TService : class;
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddScoped(Of TService As Class) (services As IServiceCollection, implementationFactory As Func(Of IServiceProvider, TService)) As IServiceCollection

类型参数

TService

要添加的服务类型。

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollection

implementationFactory
Func<IServiceProvider,TService>

用于创建服务的工厂。

返回

完成操作后对此实例的引用。

另请参阅

适用于