예제 #1
0
        internal static ReplicationStatus DeserializeReplicationStatus(JsonElement element)
        {
            Optional <AggregatedReplicationState> aggregatedState         = default;
            Optional <IReadOnlyList <RegionalReplicationStatus> > summary = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("aggregatedState"))
                {
                    aggregatedState = new AggregatedReplicationState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("summary"))
                {
                    List <RegionalReplicationStatus> array = new List <RegionalReplicationStatus>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(RegionalReplicationStatus.DeserializeRegionalReplicationStatus(item));
                    }
                    summary = array;
                    continue;
                }
            }
            return(new ReplicationStatus(Optional.ToNullable(aggregatedState), Optional.ToList(summary)));
        }
예제 #2
0
        internal static ReplicationStatus DeserializeReplicationStatus(JsonElement element)
        {
            AggregatedReplicationState?       aggregatedState = default;
            IList <RegionalReplicationStatus> summary         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("aggregatedState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    aggregatedState = new AggregatedReplicationState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("summary"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <RegionalReplicationStatus> array = new List <RegionalReplicationStatus>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(RegionalReplicationStatus.DeserializeRegionalReplicationStatus(item));
                        }
                    }
                    summary = array;
                    continue;
                }
            }
            return(new ReplicationStatus(aggregatedState, summary));
        }