Example #1
0
        public AquaContractResolver(KnownTypesRegistry knownTypes, IContractResolver?decorated = null)
        {
            if (decorated is AquaContractResolver self)
            {
                decorated = self._decorated;
            }

            _knownTypes = knownTypes.CheckNotNull(nameof(knownTypes));
            _decorated  = decorated?.GetType() == typeof(DefaultContractResolver) ? null : decorated;
        }
Example #2
0
 public Property(PropertyInfo propertyInfo, KnownTypesRegistry knownTypes)
 {
     PropertyInfo        = propertyInfo.CheckNotNull(nameof(propertyInfo));
     _knownTypes         = knownTypes.CheckNotNull(nameof(knownTypes));
     IsIgnored           = propertyInfo.GetCustomAttributes(typeof(JsonIgnoreAttribute), false).Any();
     DataMemberAttribute = (DataMemberAttribute?)propertyInfo.GetCustomAttributes(typeof(DataMemberAttribute), false)?.FirstOrDefault();
     Name             = string.IsNullOrWhiteSpace(DataMemberAttribute?.Name) ? propertyInfo.Name : DataMemberAttribute !.Name;
     EmitDefaultValue = DataMemberAttribute?.EmitDefaultValue is true;
     if (!EmitDefaultValue && propertyInfo.PropertyType.IsValueType)
     {
         DefaultValue = Activator.CreateInstance(propertyInfo.PropertyType);
     }
 }
        public RemoteLinqContractResolver(KnownTypesRegistry knownTypeRegistry, IContractResolver?decorated = null)
        {
            if (decorated is RemoteLinqContractResolver self)
            {
                decorated = self._decorated;
            }

            _knownTypeRegistry = knownTypeRegistry.CheckNotNull(nameof(knownTypeRegistry));
            _decorated         = (decorated as AquaContractResolver) ?? new AquaContractResolver(_knownTypeRegistry, decorated);
            _converters        = new Dictionary <Type, JsonConverter>
            {
                { typeof(Expression), new ExpressionConverter(_knownTypeRegistry) },
                { typeof(VariableQueryArgument), new VariableQueryArgumentConverter(_knownTypeRegistry) },
                { typeof(VariableQueryArgumentList), new VariableQueryArgumentListConverter(_knownTypeRegistry) },
            };
        }
Example #4
0
 protected ObjectConverter(KnownTypesRegistry knownTypes)
 {
     KnownTypesRegistry = knownTypes.CheckNotNull(nameof(knownTypes));
 }