Exemplo n.º 1
0
 internal OrderItemPreferences(IList <NotificationPreference> notificationPreferences, TransportPreferences transportPreferences, EncryptionPreferences encryptionPreferences, ManagementResourcePreferences managementResourcePreferences)
 {
     NotificationPreferences       = notificationPreferences;
     TransportPreferences          = transportPreferences;
     EncryptionPreferences         = encryptionPreferences;
     ManagementResourcePreferences = managementResourcePreferences;
 }
        internal static OrderItemPreferences DeserializeOrderItemPreferences(JsonElement element)
        {
            Optional <IList <NotificationPreference> > notificationPreferences       = default;
            Optional <TransportPreferences>            transportPreferences          = default;
            Optional <EncryptionPreferences>           encryptionPreferences         = default;
            Optional <ManagementResourcePreferences>   managementResourcePreferences = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("notificationPreferences"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <NotificationPreference> array = new List <NotificationPreference>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(NotificationPreference.DeserializeNotificationPreference(item));
                    }
                    notificationPreferences = array;
                    continue;
                }
                if (property.NameEquals("transportPreferences"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    transportPreferences = TransportPreferences.DeserializeTransportPreferences(property.Value);
                    continue;
                }
                if (property.NameEquals("encryptionPreferences"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    encryptionPreferences = EncryptionPreferences.DeserializeEncryptionPreferences(property.Value);
                    continue;
                }
                if (property.NameEquals("managementResourcePreferences"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    managementResourcePreferences = ManagementResourcePreferences.DeserializeManagementResourcePreferences(property.Value);
                    continue;
                }
            }
            return(new OrderItemPreferences(Optional.ToList(notificationPreferences), transportPreferences.Value, encryptionPreferences.Value, managementResourcePreferences.Value));
        }