Example #1
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));
        }