Пример #1
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (Optional.IsDefined(Services))
     {
         writer.WritePropertyName("services");
         writer.WriteObjectValue(Services);
     }
     writer.WritePropertyName("keySource");
     writer.WriteStringValue(KeySource.ToString());
     if (Optional.IsDefined(RequireInfrastructureEncryption))
     {
         writer.WritePropertyName("requireInfrastructureEncryption");
         writer.WriteBooleanValue(RequireInfrastructureEncryption.Value);
     }
     if (Optional.IsDefined(KeyVaultProperties))
     {
         writer.WritePropertyName("keyvaultproperties");
         writer.WriteObjectValue(KeyVaultProperties);
     }
     if (Optional.IsDefined(EncryptionIdentity))
     {
         writer.WritePropertyName("identity");
         writer.WriteObjectValue(EncryptionIdentity);
     }
     writer.WriteEndObject();
 }
        internal static Encryption DeserializeEncryption(JsonElement element)
        {
            Optional <EncryptionServices> services = default;
            KeySource       keySource = default;
            Optional <bool> requireInfrastructureEncryption  = default;
            Optional <KeyVaultProperties> keyvaultproperties = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("services"))
                {
                    services = EncryptionServices.DeserializeEncryptionServices(property.Value);
                    continue;
                }
                if (property.NameEquals("keySource"))
                {
                    keySource = new KeySource(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("requireInfrastructureEncryption"))
                {
                    requireInfrastructureEncryption = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("keyvaultproperties"))
                {
                    keyvaultproperties = KeyVaultProperties.DeserializeKeyVaultProperties(property.Value);
                    continue;
                }
            }
            return(new Encryption(services.Value, keySource, Optional.ToNullable(requireInfrastructureEncryption), keyvaultproperties.Value));
        }
        internal static Encryption DeserializeEncryption(JsonElement element)
        {
            EncryptionServices services           = default;
            KeySource          keySource          = default;
            bool?requireInfrastructureEncryption  = default;
            KeyVaultProperties keyvaultproperties = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("services"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    services = EncryptionServices.DeserializeEncryptionServices(property.Value);
                    continue;
                }
                if (property.NameEquals("keySource"))
                {
                    keySource = new KeySource(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("requireInfrastructureEncryption"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    requireInfrastructureEncryption = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("keyvaultproperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    keyvaultproperties = KeyVaultProperties.DeserializeKeyVaultProperties(property.Value);
                    continue;
                }
            }
            return(new Encryption(services, keySource, requireInfrastructureEncryption, keyvaultproperties));
        }
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (Services != null)
     {
         writer.WritePropertyName("services");
         writer.WriteObjectValue(Services);
     }
     writer.WritePropertyName("keySource");
     writer.WriteStringValue(KeySource.ToString());
     if (RequireInfrastructureEncryption != null)
     {
         writer.WritePropertyName("requireInfrastructureEncryption");
         writer.WriteBooleanValue(RequireInfrastructureEncryption.Value);
     }
     if (KeyVaultProperties != null)
     {
         writer.WritePropertyName("keyvaultproperties");
         writer.WriteObjectValue(KeyVaultProperties);
     }
     writer.WriteEndObject();
 }
Пример #5
0
        internal static Encryption DeserializeEncryption(JsonElement element)
        {
            Optional <EncryptionServices> services           = default;
            Optional <KeySource>          keySource          = default;
            Optional <bool> requireInfrastructureEncryption  = default;
            Optional <KeyVaultProperties> keyvaultproperties = default;
            Optional <EncryptionIdentity> identity           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("services"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    services = EncryptionServices.DeserializeEncryptionServices(property.Value);
                    continue;
                }
                if (property.NameEquals("keySource"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    keySource = new KeySource(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("requireInfrastructureEncryption"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    requireInfrastructureEncryption = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("keyvaultproperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    keyvaultproperties = KeyVaultProperties.DeserializeKeyVaultProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = EncryptionIdentity.DeserializeEncryptionIdentity(property.Value);
                    continue;
                }
            }
            return(new Encryption(services.Value, Optional.ToNullable(keySource), Optional.ToNullable(requireInfrastructureEncryption), keyvaultproperties.Value, identity.Value));
        }