語言

OpenApiDocumentTransformerContext.ApplicationServices 屬性

定義

取得與目前文件相關的應用程式服務。

public IServiceProvider ApplicationServices { get; init; }
member this.ApplicationServices : IServiceProvider with get, set
Public Property ApplicationServices As IServiceProvider

屬性值

範例

var myService = context.ApplicationServices.GetRequiredService<MyService>();

備註

這是產生 OpenAPI 文件時所用的, IServiceProvider 並可用於文件轉換器內的應用服務解析。 它通常是有作用域的提供者,例如 HttpContext.RequestServices ,或是專門為文件產生而設的範圍,但已解決服務的具體壽命取決於 OpenAPI 文件產生方式。

適用於