F# 中的动作委托
Action Delegates in F#
在 Giraffe 库示例中,我注意到以下内容:
[<EntryPoint>]
let main _ =
WebHostBuilder()
.UseKestrel()
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(configureServices)
.Build()
.Run()
0
虽然我了解其中的大部分内容,但我不清楚 Configure(Action<IApplicationBuilder> configureApp)
- configureApp
是否被转换为 Action<IApplicationBuilder>
?
更新
据我了解构造函数调用,根据 Microsoft documentation:
You initialize your objects together with constructor arguments,
either by listing the arguments in order and separated by commas and
enclosed in parentheses, or by using named arguments and values in
parentheses.
它正在创建一个新委托,使用类似于 F# 函数的委托构造函数。 C# 等价物是:
.Configure(new Action<IApplicationBuilder>(configureApp))
在 Giraffe 库示例中,我注意到以下内容:
[<EntryPoint>]
let main _ =
WebHostBuilder()
.UseKestrel()
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(configureServices)
.Build()
.Run()
0
虽然我了解其中的大部分内容,但我不清楚 Configure(Action<IApplicationBuilder> configureApp)
- configureApp
是否被转换为 Action<IApplicationBuilder>
?
更新
据我了解构造函数调用,根据 Microsoft documentation:
You initialize your objects together with constructor arguments, either by listing the arguments in order and separated by commas and enclosed in parentheses, or by using named arguments and values in parentheses.
它正在创建一个新委托,使用类似于 F# 函数的委托构造函数。 C# 等价物是:
.Configure(new Action<IApplicationBuilder>(configureApp))