문제

F #에 ServiceStack WebService를 작성하고 일부 기능 (예 : SOAP 지원 제거)을 제한해야합니다.

C # 와 같은 enableFeatures 속성에 여러 개의 enums (servicestack.servicehost.feature)를 할당하는 파이프 작업을 사용하고 있습니다.

SetConfig(new EndpointHostConfig
{
    DebugMode = true, //Show StackTraces in responses in development
    EnableFeatures = Feature.Json | Feature.Xml | Feature.Html | Feature.Metadata | Feature.Jsv
});
.

그러나 F #에서는 파이프를 사용할 수 없으며이를 수행 할 수 없으며 시도하는 모든 것은 열거 형에 대한 기능 응용 프로그램을 시도하고 있습니다.이 경우에 여러 개의 enum을 할당하는 방법은 무엇입니까?

도움이 되었습니까?

해결책

트리플 파이프를 사용하십시오 :

EnableFeatures = Feature.Json ||| Feature.Xml ||| Feature.Html ||| Feature.Metadata ||| Feature.Jsv
.

다른 팁

묶음이있는 경우 reduce가있는 키 스트로크를 몇 가지 저장할 수 있습니다.

List.reduce (|||) [Feature.Json; Feature.Xml; Feature.Html; Feature.Metadata]
.

기본 값의 구성을 기반으로 값을 생성합니다.

EnabledFeatures = enum<Feature>(16); // or whatever the full flag value would be for Json + Xml + Html + Metadata, etc
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top