internal static GalleryOSDiskImage DeserializeGalleryOSDiskImage(JsonElement element)
        {
            Optional <int>         sizeInGB                = default;
            Optional <HostCaching> hostCaching             = default;
            Optional <GalleryArtifactVersionSource> source = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sizeInGB"))
                {
                    sizeInGB = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("hostCaching"))
                {
                    hostCaching = property.Value.GetString().ToHostCaching();
                    continue;
                }
                if (property.NameEquals("source"))
                {
                    source = GalleryArtifactVersionSource.DeserializeGalleryArtifactVersionSource(property.Value);
                    continue;
                }
            }
            return(new GalleryOSDiskImage(Optional.ToNullable(sizeInGB), Optional.ToNullable(hostCaching), source.Value));
        }
        internal static GalleryImageVersionStorageProfile DeserializeGalleryImageVersionStorageProfile(JsonElement element)
        {
            Optional <GalleryArtifactVersionSource>  source         = default;
            Optional <GalleryDiskImage>              osDiskImage    = default;
            Optional <IList <GalleryDataDiskImage> > dataDiskImages = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("source"))
                {
                    source = GalleryArtifactVersionSource.DeserializeGalleryArtifactVersionSource(property.Value);
                    continue;
                }
                if (property.NameEquals("osDiskImage"))
                {
                    osDiskImage = GalleryDiskImage.DeserializeGalleryDiskImage(property.Value);
                    continue;
                }
                if (property.NameEquals("dataDiskImages"))
                {
                    List <GalleryDataDiskImage> array = new List <GalleryDataDiskImage>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(GalleryDataDiskImage.DeserializeGalleryDataDiskImage(item));
                    }
                    dataDiskImages = array;
                    continue;
                }
            }
            return(new GalleryImageVersionStorageProfile(source.Value, osDiskImage.Value, Optional.ToList(dataDiskImages)));
        }
        internal static GalleryImageVersionStorageProfile DeserializeGalleryImageVersionStorageProfile(JsonElement element)
        {
            GalleryArtifactVersionSource source         = default;
            GalleryDiskImage             osDiskImage    = default;
            IList <GalleryDataDiskImage> dataDiskImages = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("source"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    source = GalleryArtifactVersionSource.DeserializeGalleryArtifactVersionSource(property.Value);
                    continue;
                }
                if (property.NameEquals("osDiskImage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    osDiskImage = GalleryDiskImage.DeserializeGalleryDiskImage(property.Value);
                    continue;
                }
                if (property.NameEquals("dataDiskImages"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <GalleryDataDiskImage> array = new List <GalleryDataDiskImage>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(GalleryDataDiskImage.DeserializeGalleryDataDiskImage(item));
                        }
                    }
                    dataDiskImages = array;
                    continue;
                }
            }
            return(new GalleryImageVersionStorageProfile(source, osDiskImage, dataDiskImages));
        }
        internal static GalleryDataDiskImage DeserializeGalleryDataDiskImage(JsonElement element)
        {
            int                    lun                     = default;
            Optional <int>         sizeInGB                = default;
            Optional <HostCaching> hostCaching             = default;
            Optional <GalleryArtifactVersionSource> source = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("lun"))
                {
                    lun = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("sizeInGB"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sizeInGB = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("hostCaching"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hostCaching = property.Value.GetString().ToHostCaching();
                    continue;
                }
                if (property.NameEquals("source"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    source = GalleryArtifactVersionSource.DeserializeGalleryArtifactVersionSource(property.Value);
                    continue;
                }
            }
            return(new GalleryDataDiskImage(Optional.ToNullable(sizeInGB), Optional.ToNullable(hostCaching), source.Value, lun));
        }
Пример #5
0
        internal static GalleryDataDiskImage DeserializeGalleryDataDiskImage(JsonElement element)
        {
            int         lun                     = default;
            int?        sizeInGB                = default;
            HostCaching?hostCaching             = default;
            GalleryArtifactVersionSource source = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("lun"))
                {
                    lun = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("sizeInGB"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    sizeInGB = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("hostCaching"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    hostCaching = property.Value.GetString().ToHostCaching();
                    continue;
                }
                if (property.NameEquals("source"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    source = GalleryArtifactVersionSource.DeserializeGalleryArtifactVersionSource(property.Value);
                    continue;
                }
            }
            return(new GalleryDataDiskImage(sizeInGB, hostCaching, source, lun));
        }
 internal GalleryImageVersionStorageProfile(GalleryArtifactVersionSource source, GalleryOSDiskImage osDiskImage, IList <GalleryDataDiskImage> dataDiskImages)
 {
     Source         = source;
     OSDiskImage    = osDiskImage;
     DataDiskImages = dataDiskImages;
 }