Пример #1
0
        internal static DatastoreSecrets DeserializeDatastoreSecrets(JsonElement element)
        {
            if (element.TryGetProperty("secretsType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "Certificate": return(CertificateDatastoreSecrets.DeserializeCertificateDatastoreSecrets(element));

                case "KerberosKeytab": return(KerberosKeytabSecrets.DeserializeKerberosKeytabSecrets(element));

                case "KerberosPassword": return(KerberosPasswordSecrets.DeserializeKerberosPasswordSecrets(element));

                case "Sas": return(SasDatastoreSecrets.DeserializeSasDatastoreSecrets(element));

                case "ServicePrincipal": return(ServicePrincipalDatastoreSecrets.DeserializeServicePrincipalDatastoreSecrets(element));

                case "AccountKey": return(AccountKeyDatastoreSecrets.DeserializeAccountKeyDatastoreSecrets(element));
                }
            }
            SecretsType secretsType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("secretsType"))
                {
                    secretsType = new SecretsType(property.Value.GetString());
                    continue;
                }
            }
            return(new DatastoreSecrets(secretsType));
        }
Пример #2
0
        internal static AccountKeyDatastoreCredentials DeserializeAccountKeyDatastoreCredentials(JsonElement element)
        {
            AccountKeyDatastoreSecrets secrets         = default;
            CredentialsType            credentialsType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("secrets"))
                {
                    secrets = AccountKeyDatastoreSecrets.DeserializeAccountKeyDatastoreSecrets(property.Value);
                    continue;
                }
                if (property.NameEquals("credentialsType"))
                {
                    credentialsType = new CredentialsType(property.Value.GetString());
                    continue;
                }
            }
            return(new AccountKeyDatastoreCredentials(credentialsType, secrets));
        }