internal static bool IsNoSerializable(SerializeOption option, string propertyName) { return(((option.InclusiveNames != null) && !option.InclusiveNames.Contains(propertyName)) || ((option.ExclusiveNames != null) && option.ExclusiveNames.Contains(propertyName))); }
internal DeserializeBase(SerializeOption option) { this.option = option; context = new SerializeContext { Option = option }; }
internal DeserializeBase(SerializeOption option) { _option = option; _context = new SerializeContext { Option = option }; }
internal static bool IsNoSerializable(SerializeOption option, PropertyInfo property) { return(property.IsDefined <NoTextSerializableAttribute>() || (((option.InclusiveNames != null) && !option.InclusiveNames.Contains(property.Name)) || ((option.ExclusiveNames != null) && option.ExclusiveNames.Contains(property.Name))) || (((option.InclusiveMembers != null) && option.InclusiveMembers.Count(s => s.DeclaringType == property.DeclaringType) != 0 && !option.InclusiveMembers.Contains(property)) || ((option.ExclusiveMembers != null) && option.ExclusiveMembers.Contains(property)))); }
internal T GetReadableConverter(Type type, SerializeOption option) { return(typeConverters.TryGetValue(type, () => { TextConverterAttribute attr; if ((attr = type.GetCustomAttributes <TextConverterAttribute>().FirstOrDefault()) != null && typeof(JsonConverter).IsAssignableFrom(attr.ConverterType)) { return attr.ConverterType.New <T>(); } else { return (T)option.Converters.GetReadableConverter(type, new[] { typeof(T) }); } })); }
/// <summary> /// 引用另一个对象的设置属性。 /// </summary> /// <param name="other"></param> public virtual void Reference(SerializeOption other) { NamingHandling = other.NamingHandling; Converters.AddRange(other.Converters); Indent = other.Indent; ReferenceLoopHandling = other.ReferenceLoopHandling; DateFormatHandling = other.DateFormatHandling; DateTimeZoneHandling = other.DateTimeZoneHandling; NullValueHandling = other.NullValueHandling; if (other.InclusiveNames != null) { InclusiveNames = InclusiveNames == null ? other.InclusiveNames : InclusiveNames.Union(other.InclusiveNames).Distinct().ToArray(); } if (other.ExclusiveNames != null) { ExclusiveNames = ExclusiveNames == null ? other.ExclusiveNames : ExclusiveNames.Union(other.ExclusiveNames).Distinct().ToArray(); } if (other.InclusiveMembers != null) { if (InclusiveMembers != null) { InclusiveMembers.AddRange(other.InclusiveMembers); } else { InclusiveMembers = other.InclusiveMembers; } } if (other.ExclusiveMembers != null) { if (ExclusiveMembers != null) { ExclusiveMembers.AddRange(other.ExclusiveMembers); } else { ExclusiveMembers = other.ExclusiveMembers; } } }
/// <summary> /// 初始化 <see cref="DefaultContractResolver"/> 类的新实例。 /// </summary> /// <param name="option"></param> public DefaultContractResolver(SerializeOption option) { _option = option; }
internal static bool IsNoSerializable(SerializeOption option, PropertyDescriptor property) { return(property.IsDefined <NoTextSerializableAttribute>() || IsNoSerializable(option, property.Name)); }