I am writing a ServiceStack webservice in F# and need to limit some of the features (removing SOAP support for instance).
In C# I am using the pipe operation to assign multiple Enums (ServiceStack.ServiceHost.Feature) to the EnableFeatures property like so:
SetConfig(new EndpointHostConfig
{
DebugMode = true, //Show StackTraces in responses in development
EnableFeatures = Feature.Json | Feature.Xml | Feature.Html | Feature.Metadata | Feature.Jsv
});
However in F# you can't use pipe to accomplish this, and everything else I try is attempting to do function application to the enums. How do I go about assigning multiple enums in this case?
Use a triple pipe:
EnableFeatures = Feature.Json ||| Feature.Xml ||| Feature.Html ||| Feature.Metadata ||| Feature.Jsv
If you have a bunch of them you can save a few keystrokes with reduce
:
List.reduce (|||) [Feature.Json; Feature.Xml; Feature.Html; Feature.Metadata]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With