internal static EvaluatedNetworkSecurityGroup DeserializeEvaluatedNetworkSecurityGroup(JsonElement element)
        {
            string      networkSecurityGroupId = default;
            string      appliedTo   = default;
            MatchedRule matchedRule = default;
            IReadOnlyList <NetworkSecurityRulesEvaluationResult> rulesEvaluationResult = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("networkSecurityGroupId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    networkSecurityGroupId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appliedTo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    appliedTo = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("matchedRule"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    matchedRule = MatchedRule.DeserializeMatchedRule(property.Value);
                    continue;
                }
                if (property.NameEquals("rulesEvaluationResult"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <NetworkSecurityRulesEvaluationResult> array = new List <NetworkSecurityRulesEvaluationResult>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(NetworkSecurityRulesEvaluationResult.DeserializeNetworkSecurityRulesEvaluationResult(item));
                        }
                    }
                    rulesEvaluationResult = array;
                    continue;
                }
            }
            return(new EvaluatedNetworkSecurityGroup(networkSecurityGroupId, appliedTo, matchedRule, rulesEvaluationResult));
        }
Ejemplo n.º 2
0
        internal static EvaluatedNetworkSecurityGroup DeserializeEvaluatedNetworkSecurityGroup(JsonElement element)
        {
            Optional <ResourceIdentifier> networkSecurityGroupId = default;
            Optional <string>             appliedTo   = default;
            Optional <MatchedRule>        matchedRule = default;
            Optional <IReadOnlyList <NetworkSecurityRulesEvaluationResult> > rulesEvaluationResult = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("networkSecurityGroupId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    networkSecurityGroupId = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("appliedTo"))
                {
                    appliedTo = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("matchedRule"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    matchedRule = MatchedRule.DeserializeMatchedRule(property.Value);
                    continue;
                }
                if (property.NameEquals("rulesEvaluationResult"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <NetworkSecurityRulesEvaluationResult> array = new List <NetworkSecurityRulesEvaluationResult>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(NetworkSecurityRulesEvaluationResult.DeserializeNetworkSecurityRulesEvaluationResult(item));
                    }
                    rulesEvaluationResult = array;
                    continue;
                }
            }
            return(new EvaluatedNetworkSecurityGroup(networkSecurityGroupId.Value, appliedTo.Value, matchedRule.Value, Optional.ToList(rulesEvaluationResult)));
        }