Пример #1
0
        internal static DdosSettings DeserializeDdosSettings(JsonElement element)
        {
            Optional <SubResource> ddosCustomPolicy = default;
            Optional <DdosSettingsProtectionCoverage> protectionCoverage = default;
            Optional <bool> protectedIP = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("ddosCustomPolicy"))
                {
                    ddosCustomPolicy = SubResource.DeserializeSubResource(property.Value);
                    continue;
                }
                if (property.NameEquals("protectionCoverage"))
                {
                    protectionCoverage = new DdosSettingsProtectionCoverage(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("protectedIP"))
                {
                    protectedIP = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new DdosSettings(ddosCustomPolicy.Value, Optional.ToNullable(protectionCoverage), Optional.ToNullable(protectedIP)));
        }
        internal static DdosSettings DeserializeDdosSettings(JsonElement element)
        {
            SubResource ddosCustomPolicy = default;
            DdosSettingsProtectionCoverage?protectionCoverage = default;
            bool?protectedIP = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("ddosCustomPolicy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    ddosCustomPolicy = SubResource.DeserializeSubResource(property.Value);
                    continue;
                }
                if (property.NameEquals("protectionCoverage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    protectionCoverage = new DdosSettingsProtectionCoverage(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("protectedIP"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    protectedIP = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new DdosSettings(ddosCustomPolicy, protectionCoverage, protectedIP));
        }