Example #1
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("ports");
     writer.WriteStartArray();
     foreach (var item in Ports)
     {
         writer.WriteObjectValue(item);
     }
     writer.WriteEndArray();
     writer.WritePropertyName("type");
     writer.WriteStringValue(ContainerGroupIPAddressType.ToString());
     if (Optional.IsDefined(IP))
     {
         writer.WritePropertyName("ip");
         writer.WriteStringValue(IP);
     }
     if (Optional.IsDefined(DnsNameLabel))
     {
         writer.WritePropertyName("dnsNameLabel");
         writer.WriteStringValue(DnsNameLabel);
     }
     if (Optional.IsDefined(DnsNameLabelReusePolicy))
     {
         writer.WritePropertyName("dnsNameLabelReusePolicy");
         writer.WriteStringValue(DnsNameLabelReusePolicy.Value.ToString());
     }
     writer.WriteEndObject();
 }
Example #2
0
 internal IPAddress(IList <Port> ports, ContainerGroupIPAddressType containerGroupIPAddressType, string ip, string dnsNameLabel, AutoGeneratedDomainNameLabelScope?dnsNameLabelReusePolicy, string fqdn)
 {
     Ports = ports;
     ContainerGroupIPAddressType = containerGroupIPAddressType;
     IP                      = ip;
     DnsNameLabel            = dnsNameLabel;
     DnsNameLabelReusePolicy = dnsNameLabelReusePolicy;
     Fqdn                    = fqdn;
 }
Example #3
0
        public IPAddress(IEnumerable <Port> ports, ContainerGroupIPAddressType containerGroupIPAddressType)
        {
            if (ports == null)
            {
                throw new ArgumentNullException(nameof(ports));
            }

            Ports = ports.ToList();
            ContainerGroupIPAddressType = containerGroupIPAddressType;
        }
Example #4
0
        internal static IPAddress DeserializeIPAddress(JsonElement element)
        {
            IList <Port> ports = default;
            ContainerGroupIPAddressType type         = default;
            Optional <string>           ip           = default;
            Optional <string>           dnsNameLabel = default;
            Optional <AutoGeneratedDomainNameLabelScope> dnsNameLabelReusePolicy = default;
            Optional <string> fqdn = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("ports"))
                {
                    List <Port> array = new List <Port>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Port.DeserializePort(item));
                    }
                    ports = array;
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ContainerGroupIPAddressType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("ip"))
                {
                    ip = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dnsNameLabel"))
                {
                    dnsNameLabel = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dnsNameLabelReusePolicy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    dnsNameLabelReusePolicy = new AutoGeneratedDomainNameLabelScope(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("fqdn"))
                {
                    fqdn = property.Value.GetString();
                    continue;
                }
            }
            return(new IPAddress(ports, type, ip.Value, dnsNameLabel.Value, Optional.ToNullable(dnsNameLabelReusePolicy), fqdn.Value));
        }