ServiceProvider 类

定义

默认的 IServiceProvider。The default IServiceProvider.

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

方法

Dispose()

执行与释放或重置非托管资源关联的应用程序定义的任务。Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

DisposeAsync()

以异步方式执行与释放或重置非托管资源相关的应用程序定义的任务。Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

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()

返回表示当前对象的字符串。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)

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

GetRequiredService<T>(IServiceProvider)

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

GetService<T>(IServiceProvider)

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

GetServices(IServiceProvider, Type)

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

GetServices<T>(IServiceProvider)

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

ConfigureAwait(IAsyncDisposable, Boolean)

配置如何执行从异步可处置项返回的任务的等待。Configures how awaits on the tasks returned from an async disposable are performed.

适用于