Exemple #1
0
        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 GalleryDiskImage DeserializeGalleryDiskImage(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 GalleryDiskImage(Optional.ToNullable(sizeInGB), Optional.ToNullable(hostCaching), source.Value));
        }
        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;
            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));
        }
Exemple #5
0
 internal GalleryImageVersionStorageProfile(GalleryArtifactVersionSource source, GalleryDiskImage osDiskImage, IList <GalleryDataDiskImage> dataDiskImages)
 {
     Source         = source;
     OsDiskImage    = osDiskImage;
     DataDiskImages = dataDiskImages;
 }