HostBuilder.ConfigureServices(Action<HostBuilderContext,IServiceCollection>) 方法

定義

將服務新增至容器。Adds services to the container. 這可以呼叫多次,結果會進行累加。This can be called multiple times and the results will be additive.

public:
 virtual Microsoft::Extensions::Hosting::IHostBuilder ^ ConfigureServices(Action<Microsoft::Extensions::Hosting::HostBuilderContext ^, Microsoft::Extensions::DependencyInjection::IServiceCollection ^> ^ configureDelegate);
public Microsoft.Extensions.Hosting.IHostBuilder ConfigureServices (Action<Microsoft.Extensions.Hosting.HostBuilderContext,Microsoft.Extensions.DependencyInjection.IServiceCollection> configureDelegate);
abstract member ConfigureServices : Action<Microsoft.Extensions.Hosting.HostBuilderContext, Microsoft.Extensions.DependencyInjection.IServiceCollection> -> Microsoft.Extensions.Hosting.IHostBuilder
override this.ConfigureServices : Action<Microsoft.Extensions.Hosting.HostBuilderContext, Microsoft.Extensions.DependencyInjection.IServiceCollection> -> Microsoft.Extensions.Hosting.IHostBuilder
Public Function ConfigureServices (configureDelegate As Action(Of HostBuilderContext, IServiceCollection)) As IHostBuilder

參數

configureDelegate
Action<HostBuilderContext,IServiceCollection>

此委派可設定將用來為主機建構 IConfigurationIConfigurationBuilderThe delegate for configuring the IConfigurationBuilder that will be used to construct the IConfiguration for the host.

傳回

IHostBuilder

用於鏈結的相同 IHostBuilder 執行個體。The same instance of the IHostBuilder for chaining.

實作

適用於