ServiceProvider 类

定义

默认的 IServiceProvider。The default IServiceProvider.

public ref class ServiceProvider sealed : IAsyncDisposable, IDisposable, IServiceProvider
public sealed class ServiceProvider : IAsyncDisposable, IDisposable, IServiceProvider
type ServiceProvider = class
    interface IAsyncDisposable
    interface IDisposable
    interface IServiceProvider
Public NotInheritable Class ServiceProvider
Implements IAsyncDisposable, IDisposable, IServiceProvider
继承
ServiceProvider
实现

方法

Dispose()
DisposeAsync()
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetService(Type)

获取指定类型的服务对象。Gets the service object of the specified type.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

扩展方法

CreateScope(IServiceProvider)

新建可用于解析作用域内服务的 IServiceScopeCreates a new IServiceScope that can be used to resolve scoped services.

GetRequiredService(IServiceProvider, Type)

serviceType 获取类型 IServiceProvider 的服务。Get service of type serviceType from the IServiceProvider.

GetRequiredService<T>(IServiceProvider)

T 获取类型 IServiceProvider 的服务。Get service of type T from the IServiceProvider.

GetService<T>(IServiceProvider)

T 获取类型 IServiceProvider 的服务。Get service of type T from the IServiceProvider.

GetServices(IServiceProvider, Type)

serviceType 获取 IServiceProvider 类型服务的枚举。Get an enumeration of services of type serviceType from the IServiceProvider.

GetServices<T>(IServiceProvider)

T 获取 IServiceProvider 类型服务的枚举。Get an enumeration of services of type T from the IServiceProvider.

适用于