Ejemplo n.º 1
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("type");
     writer.WriteStringValue(SecurityPolicyType.ToString());
     writer.WriteEndObject();
 }
        internal static SecurityPolicyWebApplicationFirewallDefinition DeserializeSecurityPolicyWebApplicationFirewallDefinition(JsonElement element)
        {
            Optional <WritableSubResource> wafPolicy = default;
            Optional <IList <SecurityPolicyWebApplicationFirewallAssociation> > associations = default;
            SecurityPolicyType type = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("wafPolicy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    wafPolicy = JsonSerializer.Deserialize <WritableSubResource>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("associations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SecurityPolicyWebApplicationFirewallAssociation> array = new List <SecurityPolicyWebApplicationFirewallAssociation>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SecurityPolicyWebApplicationFirewallAssociation.DeserializeSecurityPolicyWebApplicationFirewallAssociation(item));
                    }
                    associations = array;
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new SecurityPolicyType(property.Value.GetString());
                    continue;
                }
            }
            return(new SecurityPolicyWebApplicationFirewallDefinition(type, wafPolicy, Optional.ToList(associations)));
        }
Ejemplo n.º 3
0
        internal static SecurityPolicyParameters DeserializeSecurityPolicyParameters(JsonElement element)
        {
            if (element.TryGetProperty("type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "WebApplicationFirewall": return(SecurityPolicyWebApplicationFirewallParameters.DeserializeSecurityPolicyWebApplicationFirewallParameters(element));
                }
            }
            SecurityPolicyType type = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = new SecurityPolicyType(property.Value.GetString());
                    continue;
                }
            }
            return(new SecurityPolicyParameters(type));
        }
Ejemplo n.º 4
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (Optional.IsDefined(WafPolicy))
     {
         writer.WritePropertyName("wafPolicy");
         JsonSerializer.Serialize(writer, WafPolicy);
     }
     if (Optional.IsCollectionDefined(Associations))
     {
         writer.WritePropertyName("associations");
         writer.WriteStartArray();
         foreach (var item in Associations)
         {
             writer.WriteObjectValue(item);
         }
         writer.WriteEndArray();
     }
     writer.WritePropertyName("type");
     writer.WriteStringValue(SecurityPolicyType.ToString());
     writer.WriteEndObject();
 }
Ejemplo n.º 5
0
 internal SecurityPolicyWebApplicationFirewallParameters(SecurityPolicyType type, WritableSubResource wafPolicy, IList <SecurityPolicyWebApplicationFirewallAssociation> associations) : base(type)
 {
     WafPolicy    = wafPolicy;
     Associations = associations;
     Type         = type;
 }
Ejemplo n.º 6
0
 internal SecurityPolicyWebApplicationFirewall(SecurityPolicyType policyType, WritableSubResource wafPolicy, IList <SecurityPolicyWebApplicationFirewallAssociation> associations) : base(policyType)
 {
     WafPolicy    = wafPolicy;
     Associations = associations;
     PolicyType   = policyType;
 }