Beispiel #1
0
        internal static NetworkProfile DeserializeNetworkProfile(JsonElement element)
        {
            Optional <IList <NetworkInterfaceReference> > networkInterfaces = default;
            Optional <NetworkApiVersion> networkApiVersion = default;
            Optional <IList <VirtualMachineNetworkInterfaceConfiguration> > networkInterfaceConfigurations = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("networkInterfaces"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <NetworkInterfaceReference> array = new List <NetworkInterfaceReference>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(NetworkInterfaceReference.DeserializeNetworkInterfaceReference(item));
                    }
                    networkInterfaces = array;
                    continue;
                }
                if (property.NameEquals("networkApiVersion"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    networkApiVersion = new NetworkApiVersion(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("networkInterfaceConfigurations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <VirtualMachineNetworkInterfaceConfiguration> array = new List <VirtualMachineNetworkInterfaceConfiguration>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VirtualMachineNetworkInterfaceConfiguration.DeserializeVirtualMachineNetworkInterfaceConfiguration(item));
                    }
                    networkInterfaceConfigurations = array;
                    continue;
                }
            }
            return(new NetworkProfile(Optional.ToList(networkInterfaces), Optional.ToNullable(networkApiVersion), Optional.ToList(networkInterfaceConfigurations)));
        }
Beispiel #2
0
        internal static VirtualMachineScaleSetNetworkProfile DeserializeVirtualMachineScaleSetNetworkProfile(JsonElement element)
        {
            Optional <WritableSubResource> healthProbe = default;
            Optional <IList <VirtualMachineScaleSetNetworkConfiguration> > networkInterfaceConfigurations = default;
            Optional <NetworkApiVersion> networkApiVersion = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("healthProbe"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    healthProbe = JsonSerializer.Deserialize <WritableSubResource>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("networkInterfaceConfigurations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <VirtualMachineScaleSetNetworkConfiguration> array = new List <VirtualMachineScaleSetNetworkConfiguration>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VirtualMachineScaleSetNetworkConfiguration.DeserializeVirtualMachineScaleSetNetworkConfiguration(item));
                    }
                    networkInterfaceConfigurations = array;
                    continue;
                }
                if (property.NameEquals("networkApiVersion"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    networkApiVersion = new NetworkApiVersion(property.Value.GetString());
                    continue;
                }
            }
            return(new VirtualMachineScaleSetNetworkProfile(healthProbe, Optional.ToList(networkInterfaceConfigurations), Optional.ToNullable(networkApiVersion)));
        }