Ejemplo n.º 1
0
 public XmlSerializeOption()
 {
     CData        = true;
     Declaration  = true;
     StartElement = true;
     Converters.AddRange(GlobalConverters.GetConverters(typeof(XmlConverter)));
 }
Ejemplo n.º 2
0
            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));
            }
Ejemplo n.º 3
0
        /// <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;
                }
            }
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 初始化 <see cref="JsonSerializeOption"/> 类的新实例。
 /// </summary>
 public JsonSerializeOption()
 {
     Indent      = false;
     KeyHandling = JsonKeyHandling.Quote;
     Converters.AddRange(GlobalConverters.GetConverters(typeof(JsonConverter)));
 }