Exemplo n.º 1
0
        public void DeserializeType <T>(JsonValue json, JsonSerializer serializer)
        {
            var type         = typeof(T);
            var propertyList = ReflectionCache.GetTypeMembers(type, serializer.Options.PropertySelectionStrategy, serializer.Options.AutoSerializeFields);
            var map          = _DeserializeTypeValues(json, serializer, propertyList, !serializer.Options.CaseSensitiveDeserialization);

            if ((json.Object.Count > 0) && (serializer.Options.InvalidPropertyKeyBehavior == InvalidPropertyKeyBehavior.ThrowException))
            {
                throw new TypeDoesNotContainPropertyException(type, json);
            }
            _AssignObjectProperties(null, map);
        }
Exemplo n.º 2
0
        public T Deserialize <T>(JsonValue json, JsonSerializer serializer)
        {
            var obj          = serializer.AbstractionMap.CreateInstance <T>(json, serializer.Options.Resolver);
            var type         = obj.GetType();
            var propertyList = ReflectionCache.GetMembers(type, serializer.Options.PropertySelectionStrategy, serializer.Options.AutoSerializeFields);
            var map          = _DeserializeValues(obj, json, serializer, propertyList, !serializer.Options.CaseSensitiveDeserialization);

            if ((json.Object.Count > 0) && (serializer.Options.InvalidPropertyKeyBehavior == InvalidPropertyKeyBehavior.ThrowException))
            {
                throw new TypeDoesNotContainPropertyException(type, json);
            }
            _AssignObjectProperties(obj, map);
            return(obj);
        }
Exemplo n.º 3
0
        public object Deserialize(DeserializationContext context)
        {
            var json         = context.LocalValue;
            var type         = context.RootSerializer.AbstractionMap.IdentifyTypeToResolve(context.InferredType, context.LocalValue);
            var propertyList = ReflectionCache.GetMembers(type, context.RootSerializer.Options.PropertySelectionStrategy, context.RootSerializer.Options.AutoSerializeFields);
            var map          = _DeserializeValues(context, propertyList, !context.RootSerializer.Options.CaseSensitiveDeserialization);

            context.ValueMap = map;
            if (json.Object.Count > 0 && context.RootSerializer.Options.InvalidPropertyKeyBehavior == InvalidPropertyKeyBehavior.ThrowException)
            {
                throw new TypeDoesNotContainPropertyException(type, json);
            }
            _AssignObjectProperties(out var obj, type, context);
            return(obj !);
        }
Exemplo n.º 4
0
        public object Deserialize(SerializationContext context)
        {
            var json         = context.LocalValue;
            var obj          = context.RootSerializer.AbstractionMap.CreateInstance(context);
            var type         = obj.GetType();
            var propertyList = ReflectionCache.GetMembers(type, context.RootSerializer.Options.PropertySelectionStrategy, context.RootSerializer.Options.AutoSerializeFields);
            var map          = _DeserializeValues(context, propertyList, !context.RootSerializer.Options.CaseSensitiveDeserialization);

            if ((json.Object.Count > 0) && (context.RootSerializer.Options.InvalidPropertyKeyBehavior == InvalidPropertyKeyBehavior.ThrowException))
            {
                throw new TypeDoesNotContainPropertyException(type, json);
            }
            _AssignObjectProperties(ref obj, map);
            return(obj);
        }