Exemplo n.º 1
0
 internal SnapshotUpdate(IDictionary <string, string> tags, SnapshotSku sku, OperatingSystemTypes?osType, int?diskSizeGB, EncryptionSettingsCollection encryptionSettingsCollection, Encryption encryption)
 {
     Tags       = tags;
     Sku        = sku;
     OsType     = osType;
     DiskSizeGB = diskSizeGB;
     EncryptionSettingsCollection = encryptionSettingsCollection;
     Encryption = encryption;
 }
Exemplo n.º 2
0
 internal Snapshot(string id, string name, string type, string location, IDictionary <string, string> tags, string managedBy, SnapshotSku sku, DateTimeOffset?timeCreated, OperatingSystemTypes?osType, HyperVGeneration?hyperVGeneration, CreationData creationData, int?diskSizeGB, long?diskSizeBytes, string uniqueId, EncryptionSettingsCollection encryptionSettingsCollection, string provisioningState, bool?incremental, Encryption encryption) : base(id, name, type, location, tags)
 {
     ManagedBy                    = managedBy;
     Sku                          = sku;
     TimeCreated                  = timeCreated;
     OsType                       = osType;
     HyperVGeneration             = hyperVGeneration;
     CreationData                 = creationData;
     DiskSizeGB                   = diskSizeGB;
     DiskSizeBytes                = diskSizeBytes;
     UniqueId                     = uniqueId;
     EncryptionSettingsCollection = encryptionSettingsCollection;
     ProvisioningState            = provisioningState;
     Incremental                  = incremental;
     Encryption                   = encryption;
 }
        internal static Snapshot DeserializeSnapshot(JsonElement element)
        {
            Optional <string>      managedBy = default;
            Optional <SnapshotSku> sku       = default;
            Optional <string>      id        = default;
            Optional <string>      name      = default;
            Optional <string>      type      = default;
            string location = default;
            Optional <IDictionary <string, string> > tags    = default;
            Optional <DateTimeOffset>       timeCreated      = default;
            Optional <OperatingSystemTypes> osType           = default;
            Optional <HyperVGeneration>     hyperVGeneration = default;
            Optional <CreationData>         creationData     = default;
            Optional <int>    diskSizeGB    = default;
            Optional <long>   diskSizeBytes = default;
            Optional <string> uniqueId      = default;
            Optional <EncryptionSettingsCollection> encryptionSettingsCollection = default;
            Optional <string>     provisioningState = default;
            Optional <bool>       incremental       = default;
            Optional <Encryption> encryption        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("managedBy"))
                {
                    managedBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    sku = SnapshotSku.DeserializeSnapshotSku(property.Value);
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("timeCreated"))
                        {
                            timeCreated = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("osType"))
                        {
                            osType = property0.Value.GetString().ToOperatingSystemTypes();
                            continue;
                        }
                        if (property0.NameEquals("hyperVGeneration"))
                        {
                            hyperVGeneration = new HyperVGeneration(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("creationData"))
                        {
                            creationData = CreationData.DeserializeCreationData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("diskSizeGB"))
                        {
                            diskSizeGB = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("diskSizeBytes"))
                        {
                            diskSizeBytes = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("uniqueId"))
                        {
                            uniqueId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("encryptionSettingsCollection"))
                        {
                            encryptionSettingsCollection = EncryptionSettingsCollection.DeserializeEncryptionSettingsCollection(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("incremental"))
                        {
                            incremental = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("encryption"))
                        {
                            encryption = Encryption.DeserializeEncryption(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new Snapshot(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), managedBy.Value, sku.Value, Optional.ToNullable(timeCreated), Optional.ToNullable(osType), Optional.ToNullable(hyperVGeneration), creationData.Value, Optional.ToNullable(diskSizeGB), Optional.ToNullable(diskSizeBytes), uniqueId.Value, encryptionSettingsCollection.Value, provisioningState.Value, Optional.ToNullable(incremental), encryption.Value));
        }
        internal static Snapshot DeserializeSnapshot(JsonElement element)
        {
            string      managedBy                 = default;
            SnapshotSku sku                       = default;
            string      id                        = default;
            string      name                      = default;
            string      type                      = default;
            string      location                  = default;
            IDictionary <string, string> tags     = default;
            DateTimeOffset?      timeCreated      = default;
            OperatingSystemTypes?osType           = default;
            HyperVGeneration?    hyperVGeneration = default;
            CreationData         creationData     = default;
            int?   diskSizeGB                     = default;
            long?  diskSizeBytes                  = default;
            string uniqueId                       = default;
            EncryptionSettingsCollection encryptionSettingsCollection = default;
            string     provisioningState = default;
            bool?      incremental       = default;
            Encryption encryption        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("managedBy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    managedBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    sku = SnapshotSku.DeserializeSnapshotSku(property.Value);
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, property0.Value.GetString());
                        }
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("timeCreated"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            timeCreated = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("osType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            osType = property0.Value.GetString().ToOperatingSystemTypes();
                            continue;
                        }
                        if (property0.NameEquals("hyperVGeneration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            hyperVGeneration = new HyperVGeneration(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("creationData"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            creationData = CreationData.DeserializeCreationData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("diskSizeGB"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            diskSizeGB = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("diskSizeBytes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            diskSizeBytes = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("uniqueId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            uniqueId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("encryptionSettingsCollection"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            encryptionSettingsCollection = EncryptionSettingsCollection.DeserializeEncryptionSettingsCollection(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("incremental"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            incremental = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("encryption"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            encryption = Encryption.DeserializeEncryption(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new Snapshot(id, name, type, location, tags, managedBy, sku, timeCreated, osType, hyperVGeneration, creationData, diskSizeGB, diskSizeBytes, uniqueId, encryptionSettingsCollection, provisioningState, incremental, encryption));
        }