ServiceStack.RestrictExtensions.ToAllowedFlagsSet C# (CSharp) Méthode

ToAllowedFlagsSet() public static méthode

Converts from a User intended restriction to a flag with all the allowed attribute flags set, e.g: If No Network restrictions were specified all Network access types are allowed, e.g: restrict EndpointAttributes.None => ... 111 If a Network restriction was specified, only it will be allowed, e.g: restrict EndpointAttributes.LocalSubnet => ... 010 The returned Enum will have a flag with all the allowed attributes set
public static ToAllowedFlagsSet ( this restrictTo ) : RequestAttributes
restrictTo this
Résultat RequestAttributes
        public static RequestAttributes ToAllowedFlagsSet(this RequestAttributes restrictTo)
        {
            if (restrictTo == RequestAttributes.Any)
                return RequestAttributes.Any;

            var allowedAttrs = RequestAttributes.None;

            //Network access
            if (!HasAnyRestrictionsOf(restrictTo, RequestAttributes.AnyNetworkAccessType))
                allowedAttrs |= RequestAttributes.AnyNetworkAccessType;
            else
                allowedAttrs |= (restrictTo & RequestAttributes.AnyNetworkAccessType);

            //Security
            if (!HasAnyRestrictionsOf(restrictTo, RequestAttributes.AnySecurityMode))
                allowedAttrs |= RequestAttributes.AnySecurityMode;
            else
                allowedAttrs |= (restrictTo & RequestAttributes.AnySecurityMode);

            //Http Method
            if (!HasAnyRestrictionsOf(restrictTo, RequestAttributes.AnyHttpMethod))
                allowedAttrs |= RequestAttributes.AnyHttpMethod;
            else
                allowedAttrs |= (restrictTo & RequestAttributes.AnyHttpMethod);

            //Call Style
            if (!HasAnyRestrictionsOf(restrictTo, RequestAttributes.AnyCallStyle))
                allowedAttrs |= RequestAttributes.AnyCallStyle;
            else
                allowedAttrs |= (restrictTo & RequestAttributes.AnyCallStyle);

            //Format
            if (!HasAnyRestrictionsOf(restrictTo, RequestAttributes.AnyFormat))
                allowedAttrs |= RequestAttributes.AnyFormat;
            else
                allowedAttrs |= (restrictTo & RequestAttributes.AnyFormat);

            //Endpoint
            if (!HasAnyRestrictionsOf(restrictTo, RequestAttributes.AnyEndpoint))
                allowedAttrs |= RequestAttributes.AnyEndpoint;
            else
                allowedAttrs |= (restrictTo & RequestAttributes.AnyEndpoint);

            return allowedAttrs;
        }