public XmlSerializeOption() { CData = true; Declaration = true; StartElement = true; Converters.AddRange(GlobalConverters.GetConverters(typeof(XmlConverter))); }
public ValueBinder <TParams, TField> Compile(bool withDefaults) { IEnumerable <Converter <TField> > converters; if (withDefaults) { Converter <TField>[] defaultConverters = DefaultConverters.To <TField>(); if (Converters.Count > 0) { Converters.AddRange(defaultConverters); converters = Converters; } else { converters = defaultConverters; } } else { converters = Converters; } return(new ValueBinder <TParams, TField>( Member?.Name, CompileGetter(Member), converters)); }
/// <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; } } }
public TotemSerializerSettings() { Formatting = Formatting.Indented; TypeNameHandling = TypeNameHandling.Auto; ContractResolver = new TotemContractResolver(); Binder = new TotemSerializationBinder(); Converters.AddRange( new StringEnumConverter(), new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal, DateTimeFormat = DateTimeFormatInfo.InvariantInfo.UniversalSortableDateTimePattern }); DateTimeZoneHandling = DateTimeZoneHandling.Utc; DateFormatHandling = DateFormatHandling.IsoDateFormat; }
/// <summary> /// 初始化 <see cref="JsonSerializeOption"/> 类的新实例。 /// </summary> public JsonSerializeOption() { Indent = false; KeyHandling = JsonKeyHandling.Quote; Converters.AddRange(GlobalConverters.GetConverters(typeof(JsonConverter))); }