Exemplo n.º 1
0
 internal DiskEncryptionSet(string id, string name, string type, string location, IDictionary <string, string> tags, EncryptionSetIdentity identity, KeyVaultAndKeyReference activeKey, IList <KeyVaultAndKeyReference> previousKeys, string provisioningState) : base(id, name, type, location, tags)
 {
     Identity          = identity;
     ActiveKey         = activeKey;
     PreviousKeys      = previousKeys;
     ProvisioningState = provisioningState;
 }
        internal static DiskEncryptionSet DeserializeDiskEncryptionSet(JsonElement element)
        {
            Optional <EncryptionSetIdentity> identity = default;
            Optional <string> id       = default;
            Optional <string> name     = default;
            Optional <string> type     = default;
            string            location = default;
            Optional <IDictionary <string, string> >            tags         = default;
            Optional <KeyVaultAndKeyReference>                  activeKey    = default;
            Optional <IReadOnlyList <KeyVaultAndKeyReference> > previousKeys = default;
            Optional <string> provisioningState = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("identity"))
                {
                    identity = EncryptionSetIdentity.DeserializeEncryptionSetIdentity(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("activeKey"))
                        {
                            activeKey = KeyVaultAndKeyReference.DeserializeKeyVaultAndKeyReference(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("previousKeys"))
                        {
                            List <KeyVaultAndKeyReference> array = new List <KeyVaultAndKeyReference>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(KeyVaultAndKeyReference.DeserializeKeyVaultAndKeyReference(item));
                            }
                            previousKeys = array;
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new DiskEncryptionSet(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), identity.Value, activeKey.Value, Optional.ToList(previousKeys), provisioningState.Value));
        }
Exemplo n.º 3
0
        internal static DiskEncryptionSet DeserializeDiskEncryptionSet(JsonElement element)
        {
            EncryptionSetIdentity identity = default;
            string id       = default;
            string name     = default;
            string type     = default;
            string location = default;
            IDictionary <string, string>    tags         = default;
            KeyVaultAndKeyReference         activeKey    = default;
            IList <KeyVaultAndKeyReference> previousKeys = default;
            string provisioningState = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    identity = EncryptionSetIdentity.DeserializeEncryptionSetIdentity(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("activeKey"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            activeKey = KeyVaultAndKeyReference.DeserializeKeyVaultAndKeyReference(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("previousKeys"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            List <KeyVaultAndKeyReference> array = new List <KeyVaultAndKeyReference>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                if (item.ValueKind == JsonValueKind.Null)
                                {
                                    array.Add(null);
                                }
                                else
                                {
                                    array.Add(KeyVaultAndKeyReference.DeserializeKeyVaultAndKeyReference(item));
                                }
                            }
                            previousKeys = array;
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new DiskEncryptionSet(id, name, type, location, tags, identity, activeKey, previousKeys, provisioningState));
        }