我正在用 F# 编写 ServiceStack Web 服务,需要限制某些功能(例如删除 SOAP 支持)。
在 C# 中,我使用管道操作将多个枚举 (ServiceStack.ServiceHost.Feature) 分配给 EnableFeatures 属性,如下所示:
SetConfig(new EndpointHostConfig
{
DebugMode = true, //Show StackTraces in responses in development
EnableFeatures = Feature.Json | Feature.Xml | Feature.Html | Feature.Metadata | Feature.Jsv
});
但是,在 F# 中,您无法使用管道来完成此操作,我尝试的其他所有操作都是尝试对枚举进行函数应用。在这种情况下,我该如何分配多个枚举?
最佳答案
使用三管:
EnableFeatures = Feature.Json ||| Feature.Xml ||| Feature.Html ||| Feature.Metadata ||| Feature.Jsv
关于f# - 在 F# 中将多个枚举值分配给属性的语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10655679/