Beispiel #1
0
 internal VirtualMachineSize(string name, string family, int?vcpUs, int?gpus, int?osVhdSizeMB, int?maxResourceVolumeMB, double?memoryGB, bool?lowPriorityCapable, bool?premiumIO, EstimatedVmPrices estimatedVmPrices, IReadOnlyList <string> supportedComputeTypes)
 {
     Name                  = name;
     Family                = family;
     VCPUs                 = vcpUs;
     Gpus                  = gpus;
     OSVhdSizeMB           = osVhdSizeMB;
     MaxResourceVolumeMB   = maxResourceVolumeMB;
     MemoryGB              = memoryGB;
     LowPriorityCapable    = lowPriorityCapable;
     PremiumIO             = premiumIO;
     EstimatedVmPrices     = estimatedVmPrices;
     SupportedComputeTypes = supportedComputeTypes;
 }
Beispiel #2
0
        internal static VirtualMachineSize DeserializeVirtualMachineSize(JsonElement element)
        {
            Optional <string>                  name                  = default;
            Optional <string>                  family                = default;
            Optional <int>                     vcpUs                 = default;
            Optional <int>                     gpus                  = default;
            Optional <int>                     osVhdSizeMB           = default;
            Optional <int>                     maxResourceVolumeMB   = default;
            Optional <double>                  memoryGB              = default;
            Optional <bool>                    lowPriorityCapable    = default;
            Optional <bool>                    premiumIO             = default;
            Optional <EstimatedVmPrices>       estimatedVMPrices     = default;
            Optional <IReadOnlyList <string> > supportedComputeTypes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("family"))
                {
                    family = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("vCPUs"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    vcpUs = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("gpus"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    gpus = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("osVhdSizeMB"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    osVhdSizeMB = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("maxResourceVolumeMB"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    maxResourceVolumeMB = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("memoryGB"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    memoryGB = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("lowPriorityCapable"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    lowPriorityCapable = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("premiumIO"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    premiumIO = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("estimatedVMPrices"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    estimatedVMPrices = EstimatedVmPrices.DeserializeEstimatedVmPrices(property.Value);
                    continue;
                }
                if (property.NameEquals("supportedComputeTypes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    supportedComputeTypes = array;
                    continue;
                }
            }
            return(new VirtualMachineSize(name.Value, family.Value, Optional.ToNullable(vcpUs), Optional.ToNullable(gpus), Optional.ToNullable(osVhdSizeMB), Optional.ToNullable(maxResourceVolumeMB), Optional.ToNullable(memoryGB), Optional.ToNullable(lowPriorityCapable), Optional.ToNullable(premiumIO), estimatedVMPrices.Value, Optional.ToList(supportedComputeTypes)));
        }