예제 #1
0
        internal static PolicySettings DeserializePolicySettings(JsonElement element)
        {
            WebApplicationFirewallEnabledState?state = default;
            WebApplicationFirewallMode?        mode  = default;
            bool?requestBodyCheck       = default;
            int? maxRequestBodySizeInKb = default;
            int? fileUploadLimitInMb    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("state"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    state = new WebApplicationFirewallEnabledState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("mode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    mode = new WebApplicationFirewallMode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("requestBodyCheck"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    requestBodyCheck = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("maxRequestBodySizeInKb"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    maxRequestBodySizeInKb = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("fileUploadLimitInMb"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    fileUploadLimitInMb = property.Value.GetInt32();
                    continue;
                }
            }
            return(new PolicySettings(state, mode, requestBodyCheck, maxRequestBodySizeInKb, fileUploadLimitInMb));
        }
        internal static PolicySettings DeserializePolicySettings(JsonElement element)
        {
            Optional <WebApplicationFirewallEnabledState> state = default;
            Optional <WebApplicationFirewallMode>         mode  = default;
            Optional <bool> requestBodyCheck       = default;
            Optional <int>  maxRequestBodySizeInKb = default;
            Optional <int>  fileUploadLimitInMb    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("state"))
                {
                    state = new WebApplicationFirewallEnabledState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("mode"))
                {
                    mode = new WebApplicationFirewallMode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("requestBodyCheck"))
                {
                    requestBodyCheck = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("maxRequestBodySizeInKb"))
                {
                    maxRequestBodySizeInKb = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("fileUploadLimitInMb"))
                {
                    fileUploadLimitInMb = property.Value.GetInt32();
                    continue;
                }
            }
            return(new PolicySettings(Optional.ToNullable(state), Optional.ToNullable(mode), Optional.ToNullable(requestBodyCheck), Optional.ToNullable(maxRequestBodySizeInKb), Optional.ToNullable(fileUploadLimitInMb)));
        }