HostingHostBuilderExtensions.ConfigureServices(IHostBuilder, Action<IServiceCollection>) 方法

定義

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

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::Hosting::IHostBuilder ^ ConfigureServices(Microsoft::Extensions::Hosting::IHostBuilder ^ hostBuilder, Action<Microsoft::Extensions::DependencyInjection::IServiceCollection ^> ^ configureDelegate);
public static Microsoft.Extensions.Hosting.IHostBuilder ConfigureServices (this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, Action<Microsoft.Extensions.DependencyInjection.IServiceCollection> configureDelegate);
static member ConfigureServices : Microsoft.Extensions.Hosting.IHostBuilder * Action<Microsoft.Extensions.DependencyInjection.IServiceCollection> -> Microsoft.Extensions.Hosting.IHostBuilder
<Extension()>
Public Function ConfigureServices (hostBuilder As IHostBuilder, configureDelegate As Action(Of IServiceCollection)) As IHostBuilder

參數

hostBuilder
IHostBuilder

要設定的 IHostBuilderThe IHostBuilder to configure.

configureDelegate
Action<IServiceCollection>

用於設定 IServiceCollection 的委派。The delegate for configuring the IServiceCollection.

傳回

IHostBuilder

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

適用於