internal static GeoReplicationStats DeserializeGeoReplicationStats(JsonElement element)
        {
            Optional <GeoReplicationStatus> status       = default;
            Optional <DateTimeOffset>       lastSyncTime = default;
            Optional <bool> canFailover = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    status = new GeoReplicationStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("lastSyncTime"))
                {
                    lastSyncTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("canFailover"))
                {
                    canFailover = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new GeoReplicationStats(Optional.ToNullable(status), Optional.ToNullable(lastSyncTime), Optional.ToNullable(canFailover)));
        }
Esempio n. 2
0
        internal static GeoReplicationStats DeserializeGeoReplicationStats(JsonElement element)
        {
            GeoReplicationStatus?status       = default;
            DateTimeOffset?      lastSyncTime = default;
            bool?canFailover = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    status = new GeoReplicationStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("lastSyncTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastSyncTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("canFailover"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    canFailover = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new GeoReplicationStats(status, lastSyncTime, canFailover));
        }