你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
MiddlewareWorkerApplicationBuilderExtensions.UseWhen 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
UseWhen(IFunctionsWorkerApplicationBuilder, Func<FunctionContext,Boolean>, Func<FunctionContext,Func<Task>,Task>) |
将 IFunctionsWorkerApplicationBuilder 配置为在提供的谓词表达式返回 true 时使用提供的内联中间件委托。 |
UseWhen<T>(IFunctionsWorkerApplicationBuilder, Func<FunctionContext,Boolean>) |
将 IFunctionsWorkerApplicationBuilder 配置为在提供的谓词表达式返回 true 时使用提供的中间件类型。 |
UseWhen(IFunctionsWorkerApplicationBuilder, Func<FunctionContext,Boolean>, Func<FunctionContext,Func<Task>,Task>)
将 IFunctionsWorkerApplicationBuilder 配置为在提供的谓词表达式返回 true 时使用提供的内联中间件委托。
public static Microsoft.Azure.Functions.Worker.IFunctionsWorkerApplicationBuilder UseWhen (this Microsoft.Azure.Functions.Worker.IFunctionsWorkerApplicationBuilder builder, Func<Microsoft.Azure.Functions.Worker.FunctionContext,bool> predicate, Func<Microsoft.Azure.Functions.Worker.FunctionContext,Func<System.Threading.Tasks.Task>,System.Threading.Tasks.Task> middleware);
static member UseWhen : Microsoft.Azure.Functions.Worker.IFunctionsWorkerApplicationBuilder * Func<Microsoft.Azure.Functions.Worker.FunctionContext, bool> * Func<Microsoft.Azure.Functions.Worker.FunctionContext, Func<System.Threading.Tasks.Task>, System.Threading.Tasks.Task> -> Microsoft.Azure.Functions.Worker.IFunctionsWorkerApplicationBuilder
<Extension()>
Public Function UseWhen (builder As IFunctionsWorkerApplicationBuilder, predicate As Func(Of FunctionContext, Boolean), middleware As Func(Of FunctionContext, Func(Of Task), Task)) As IFunctionsWorkerApplicationBuilder
参数
- predicate
- Func<FunctionContext,Boolean>
调用的谓词,用于确定是否应在函数调用期间执行中间件。
- middleware
- Func<FunctionContext,Func<Task>,Task>
要添加到调用管道的中间件。
返回
链接也是如此 IFunctionsWorkerApplicationBuilder 。
适用于
UseWhen<T>(IFunctionsWorkerApplicationBuilder, Func<FunctionContext,Boolean>)
将 IFunctionsWorkerApplicationBuilder 配置为在提供的谓词表达式返回 true 时使用提供的中间件类型。
public static Microsoft.Azure.Functions.Worker.IFunctionsWorkerApplicationBuilder UseWhen<T> (this Microsoft.Azure.Functions.Worker.IFunctionsWorkerApplicationBuilder builder, Func<Microsoft.Azure.Functions.Worker.FunctionContext,bool> predicate) where T : class, Microsoft.Azure.Functions.Worker.Middleware.IFunctionsWorkerMiddleware;
static member UseWhen : Microsoft.Azure.Functions.Worker.IFunctionsWorkerApplicationBuilder * Func<Microsoft.Azure.Functions.Worker.FunctionContext, bool> -> Microsoft.Azure.Functions.Worker.IFunctionsWorkerApplicationBuilder (requires 'T : null and 'T :> Microsoft.Azure.Functions.Worker.Middleware.IFunctionsWorkerMiddleware)
<Extension()>
Public Function UseWhen(Of T As {Class, IFunctionsWorkerMiddleware}) (builder As IFunctionsWorkerApplicationBuilder, predicate As Func(Of FunctionContext, Boolean)) As IFunctionsWorkerApplicationBuilder
类型参数
- T
参数
- predicate
- Func<FunctionContext,Boolean>
调用的谓词,用于确定是否应在函数调用期间执行中间件。
返回
用于链接的相同 IFunctionsWorkerApplicationBuilder 实例。