コード例 #1
0
        internal static StorageProfile DeserializeStorageProfile(JsonElement element)
        {
            Optional <ImageReference>    imageReference = default;
            Optional <OSDisk>            osDisk         = default;
            Optional <IList <DataDisk> > dataDisks      = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("imageReference"))
                {
                    imageReference = ImageReference.DeserializeImageReference(property.Value);
                    continue;
                }
                if (property.NameEquals("osDisk"))
                {
                    osDisk = OSDisk.DeserializeOSDisk(property.Value);
                    continue;
                }
                if (property.NameEquals("dataDisks"))
                {
                    List <DataDisk> array = new List <DataDisk>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DataDisk.DeserializeDataDisk(item));
                    }
                    dataDisks = array;
                    continue;
                }
            }
            return(new StorageProfile(imageReference.Value, osDisk.Value, Optional.ToList(dataDisks)));
        }
コード例 #2
0
        internal static StorageProfile DeserializeStorageProfile(JsonElement element)
        {
            ImageReference   imageReference = default;
            OSDisk           osDisk         = default;
            IList <DataDisk> dataDisks      = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("imageReference"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    imageReference = ImageReference.DeserializeImageReference(property.Value);
                    continue;
                }
                if (property.NameEquals("osDisk"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    osDisk = OSDisk.DeserializeOSDisk(property.Value);
                    continue;
                }
                if (property.NameEquals("dataDisks"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <DataDisk> array = new List <DataDisk>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(DataDisk.DeserializeDataDisk(item));
                        }
                    }
                    dataDisks = array;
                    continue;
                }
            }
            return(new StorageProfile(imageReference, osDisk, dataDisks));
        }