Наследование: Newtonsoft.Json.Serialization.DefaultContractResolver
Пример #1
0
        public JsonNetSerializer()
        {
            _settings = new JsonSerializerSettings();

            var customResolver = new CustomIgnoreResolver
            {
                DefaultMembersSearchFlags = BindingFlags.Instance | BindingFlags.Public
            };

            _settings.ContractResolver = customResolver;

            //var javaScriptDateTimeConverter = new JavaScriptDateTimeConverter();

            //_settings.Converters.Add(javaScriptDateTimeConverter);
            _settings.Converters.Add(new EntityKeyMemberConverter());
            _settings.Converters.Add(new KeyValuePairConverter());
            _settings.Converters.Add(new ExpandoObjectConverter());
            _settings.Converters.Add(new XmlNodeConverter());

            _settings.DateFormatHandling    = DateFormatHandling.IsoDateFormat;
            _settings.DateParseHandling     = DateParseHandling.DateTimeOffset;
            _settings.DateTimeZoneHandling  = DateTimeZoneHandling.RoundtripKind;
            _settings.NullValueHandling     = NullValueHandling.Include;
            _settings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
            _settings.TypeNameHandling      = TypeNameHandling.Objects;
            _settings.ConstructorHandling   = ConstructorHandling.AllowNonPublicDefaultConstructor;
        }
Пример #2
0
        public JsonNetSerialiser()
        {
            _settings = new JsonSerializerSettings();

            var customResolver = new CustomIgnoreResolver
                {
                    DefaultMembersSearchFlags = BindingFlags.Instance | BindingFlags.Public
                };
            _settings.ContractResolver = customResolver;

            var javaScriptDateTimeConverter = new JavaScriptDateTimeConverter();

            _settings.Converters.Add(javaScriptDateTimeConverter);
            _settings.Converters.Add(new EntityKeyMemberConverter());
            _settings.Converters.Add(new KeyValuePairConverter());
            _settings.Converters.Add(new ExpandoObjectConverter());
            _settings.Converters.Add(new XmlNodeConverter());

            _settings.NullValueHandling = NullValueHandling.Include;
            _settings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
            _settings.TypeNameHandling = TypeNameHandling.Objects;
            _settings.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
        }