ServiceCollectionDescriptorExtensions.Replace(IServiceCollection, ServiceDescriptor) 方法

定義

移除 IServiceCollection 中具有與 descriptor 相同服務類型的第一個服務,並將 descriptor 新增至集合。Removes the first service in IServiceCollection with the same service type as descriptor and adds descriptor to the collection.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ Replace(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ descriptor);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection Replace (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor);
static member Replace : Microsoft.Extensions.DependencyInjection.IServiceCollection * Microsoft.Extensions.DependencyInjection.ServiceDescriptor -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function Replace (collection As IServiceCollection, descriptor As ServiceDescriptor) As IServiceCollection

參數

descriptor
ServiceDescriptor

要取代為的 ServiceDescriptorThe ServiceDescriptor to replace with.

傳回

用於鏈結的 IServiceCollectionThe IServiceCollection for chaining.

適用於