我正在尝试使用来自F#的C#扩展方法和流畅的API,但我无法弄清楚如何做到这一点。以下代码片段以Asp.Net Core RC2为例:
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
我无法弄清楚如何使用F#这样的API。如果有人有使用F#中的流畅API的经验,也许他们可以对它有所启发。
答案 0 :(得分:2)
以下C#'hello world'示例的翻译对我有用:
open System
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Http
type Startup () =
member this.Configure(app: IApplicationBuilder) =
app.Run(fun context -> context.Response.WriteAsync("Hello world!"))
[<EntryPoint>]
let main argv =
let builder = new WebHostBuilder()
let host = builder.UseKestrel().UseStartup<Startup>().Build()
host.Run()
0
答案 1 :(得分:0)
尝试添加完整的AspNetCore包。
dynamic query = new ExpandoObject();
query.size = 10;
query.date = "2017-04-27";
dynamic match = new {
query = query,
bool = true
}
你很可能错过了什么。