public static void Manipulate( MemberInfo member, Encrypter encrypter, JsonProperty property) { var containsEncryptAttribute = member.ContainsEncryptAttribute(); var containsNodeEncryptAttribute = member.ContainsNodeEncryptAttribute(); if (!containsEncryptAttribute && !containsNodeEncryptAttribute) { return; } if (containsEncryptAttribute && containsNodeEncryptAttribute) { throw new($"Cannot contain both {nameof(EncryptAttribute)} and {nameof(NodeEncryptAttribute)}."); } if (containsNodeEncryptAttribute) { if (property.Converter == null) { property.Converter = new NodeConverter(encrypter); return; } property.Converter = new WrappedNodeConverter(encrypter, property.Converter); return; } var memberType = member.GetUnderlyingType(); if (memberType == typeof(string)) { VerifyConverterIsNull(property, member); property.Converter = new StringConverter(encrypter); return; } if (memberType.IsStringDictionary()) { VerifyItemConverterIsNull(property, member); property.ItemConverter = new StringConverter(encrypter); return; } if (memberType.IsStringEnumerable()) { VerifyItemConverterIsNull(property, member); property.ItemConverter = new StringConverter(encrypter); return; } if (memberType == typeof(Guid)) { VerifyConverterIsNull(property, member); property.Converter = new GuidConverter(encrypter); return; } if (memberType.IsGuidDictionary()) { VerifyItemConverterIsNull(property, member); property.ItemConverter = new GuidConverter(encrypter); return; } if (memberType.IsGuidEnumerable()) { VerifyItemConverterIsNull(property, member); property.ItemConverter = new GuidConverter(encrypter); return; } if (memberType == typeof(byte[])) { VerifyConverterIsNull(property, member); property.Converter = new ByteArrayConverter(encrypter); return; } if (memberType.IsByteArrayDictionary()) { VerifyItemConverterIsNull(property, member); property.ItemConverter = new ByteArrayConverter(encrypter); return; } if (memberType.IsByteArrayEnumerable()) { VerifyItemConverterIsNull(property, member); property.ItemConverter = new ByteArrayConverter(encrypter); return; } throw new("Expected a string, a IDictionary<T,string>, a IEnumerable<string>, a Guid, a IDictionary<T,Guid>, a IEnumerable<Guid>, a byte[], a IDictionary<T,byte[]>, or a IEnumerable<byte[]>."); }