예제 #1
0
        internal static EncryptionKey DeserializeEncryptionKey(JsonElement element)
        {
            EncryptionKey result = new EncryptionKey();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("keyVaultKeyName"))
                {
                    result.KeyVaultKeyName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("keyVaultKeyVersion"))
                {
                    result.KeyVaultKeyVersion = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("keyVaultUri"))
                {
                    result.KeyVaultUri = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("accessCredentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.AccessCredentials = AzureActiveDirectoryApplicationCredentials.DeserializeAzureActiveDirectoryApplicationCredentials(property.Value);
                    continue;
                }
            }
            return(result);
        }
        internal static SearchResourceEncryptionKey DeserializeSearchResourceEncryptionKey(JsonElement element)
        {
            string keyVaultKeyName    = default;
            string keyVaultKeyVersion = default;
            string keyVaultUri        = default;
            AzureActiveDirectoryApplicationCredentials accessCredentials = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("keyVaultKeyName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    keyVaultKeyName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("keyVaultKeyVersion"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    keyVaultKeyVersion = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("keyVaultUri"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    keyVaultUri = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("accessCredentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    accessCredentials = AzureActiveDirectoryApplicationCredentials.DeserializeAzureActiveDirectoryApplicationCredentials(property.Value);
                    continue;
                }
            }
            return(new SearchResourceEncryptionKey(keyVaultKeyName, keyVaultKeyVersion, keyVaultUri, accessCredentials));
        }