Esempio n. 1
0
        internal static PartnerRegionInfo DeserializePartnerRegionInfo(JsonElement element)
        {
            Optional <string> location = default;
            Optional <InstanceFailoverGroupReplicationRole> replicationRole = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("replicationRole"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    replicationRole = new InstanceFailoverGroupReplicationRole(property.Value.GetString());
                    continue;
                }
            }
            return(new PartnerRegionInfo(location.Value, Optional.ToNullable(replicationRole)));
        }
        internal static InstanceFailoverGroup DeserializeInstanceFailoverGroup(JsonElement element)
        {
            Optional <string> id   = default;
            Optional <string> name = default;
            Optional <string> type = default;
            Optional <InstanceFailoverGroupReadWriteEndpoint> readWriteEndpoint = default;
            Optional <InstanceFailoverGroupReadOnlyEndpoint>  readOnlyEndpoint  = default;
            Optional <InstanceFailoverGroupReplicationRole>   replicationRole   = default;
            Optional <string> replicationState = default;
            Optional <IList <PartnerRegionInfo> >       partnerRegions       = default;
            Optional <IList <ManagedInstancePairInfo> > managedInstancePairs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("readWriteEndpoint"))
                        {
                            readWriteEndpoint = InstanceFailoverGroupReadWriteEndpoint.DeserializeInstanceFailoverGroupReadWriteEndpoint(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("readOnlyEndpoint"))
                        {
                            readOnlyEndpoint = InstanceFailoverGroupReadOnlyEndpoint.DeserializeInstanceFailoverGroupReadOnlyEndpoint(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("replicationRole"))
                        {
                            replicationRole = new InstanceFailoverGroupReplicationRole(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("replicationState"))
                        {
                            replicationState = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("partnerRegions"))
                        {
                            List <PartnerRegionInfo> array = new List <PartnerRegionInfo>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(PartnerRegionInfo.DeserializePartnerRegionInfo(item));
                            }
                            partnerRegions = array;
                            continue;
                        }
                        if (property0.NameEquals("managedInstancePairs"))
                        {
                            List <ManagedInstancePairInfo> array = new List <ManagedInstancePairInfo>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ManagedInstancePairInfo.DeserializeManagedInstancePairInfo(item));
                            }
                            managedInstancePairs = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new InstanceFailoverGroup(id.Value, name.Value, type.Value, readWriteEndpoint.Value, readOnlyEndpoint.Value, Optional.ToNullable(replicationRole), replicationState.Value, Optional.ToList(partnerRegions), Optional.ToList(managedInstancePairs)));
        }