Joh*_*air 10 enums f# servicestack
我正在用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
});
Run Code Online (Sandbox Code Playgroud)
但是在F#中你不能使用管道来完成这个,我尝试的其他一切都试图对枚举进行功能应用.在这种情况下,如何分配多个枚举?
Cra*_*ntz 18
使用三管:
EnableFeatures = Feature.Json ||| Feature.Xml ||| Feature.Html ||| Feature.Metadata ||| Feature.Jsv
Run Code Online (Sandbox Code Playgroud)
Dan*_*iel 12
如果你有一堆,你可以用以下方法保存一些按键reduce:
List.reduce (|||) [Feature.Json; Feature.Xml; Feature.Html; Feature.Metadata]
Run Code Online (Sandbox Code Playgroud)