Exemplo n.º 1
0
        private static JsonPropertyInfo AddProperty(
            MemberInfo memberInfo,
            Type memberType,
            Type parentClassType,
            bool isVirtual,
            JsonSerializerOptions options)
        {
            JsonIgnoreCondition?ignoreCondition = JsonPropertyInfo.GetAttribute <JsonIgnoreAttribute>(memberInfo)?.Condition;

            if (ignoreCondition == JsonIgnoreCondition.Always)
            {
                return(JsonPropertyInfo.CreateIgnoredPropertyPlaceholder(memberInfo, memberType, isVirtual, options));
            }

            ValidateType(memberType, parentClassType, memberInfo, options);

            JsonConverter converter = GetConverter(
                memberType,
                parentClassType,
                memberInfo,
                options);

            return(CreateProperty(
                       declaredPropertyType: memberType,
                       memberInfo,
                       parentClassType,
                       isVirtual,
                       converter,
                       options,
                       ignoreCondition));
        }
Exemplo n.º 2
0
        internal static JsonPropertyInfo AddProperty(
            MemberInfo memberInfo,
            Type memberType,
            Type parentClassType,
            bool isVirtual,
            JsonNumberHandling?parentTypeNumberHandling,
            JsonSerializerOptions options)
        {
            JsonIgnoreCondition?ignoreCondition = JsonPropertyInfo.GetAttribute <JsonIgnoreAttribute>(memberInfo)?.Condition;

            if (ignoreCondition == JsonIgnoreCondition.Always)
            {
                return(JsonPropertyInfo.CreateIgnoredPropertyPlaceholder(memberInfo, memberType, isVirtual, options));
            }

            JsonConverter converter = GetConverter(
                memberType,
                parentClassType,
                memberInfo,
                out Type runtimeType,
                options);

            return(CreateProperty(
                       declaredPropertyType: memberType,
                       runtimePropertyType: runtimeType,
                       memberInfo,
                       parentClassType,
                       isVirtual,
                       converter,
                       options,
                       parentTypeNumberHandling,
                       ignoreCondition));
        }