示例#1
0
        internal static ServiceBusRuleData DeserializeServiceBusRuleData(JsonElement element)
        {
            ResourceIdentifier           id                = default;
            string                       name              = default;
            ResourceType                 type              = default;
            SystemData                   systemData        = default;
            Optional <FilterAction>      action            = default;
            Optional <FilterType>        filterType        = default;
            Optional <SqlFilter>         sqlFilter         = default;
            Optional <CorrelationFilter> correlationFilter = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("action"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            action = FilterAction.DeserializeFilterAction(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("filterType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            filterType = property0.Value.GetString().ToFilterType();
                            continue;
                        }
                        if (property0.NameEquals("sqlFilter"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            sqlFilter = SqlFilter.DeserializeSqlFilter(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("correlationFilter"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            correlationFilter = CorrelationFilter.DeserializeCorrelationFilter(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ServiceBusRuleData(id, name, type, systemData, action.Value, Optional.ToNullable(filterType), sqlFilter.Value, correlationFilter.Value));
        }