Example #1
0
 ItemDeserializer CreateItemDeserializer(Type type)
 {
     if (TypeDeserializers != null && TypeDeserializers.ContainsKey(type))
     {
         var method = TypeDeserializers[type];
         return((obj, context) => method.Invoke(obj, new[] { context }));
     }
     else
     {
         var deserializer = GetDeserializerForType(type);
         return((obj, context) => deserializer(context));
     }
 }
Example #2
0
        ObjectDeserializer CreateCustomDeserializer(PropertyInfo property)
        {
            if (!property.CanWrite)
            {
                // TODO throw
            }

            if (TypeDeserializers != null && TypeDeserializers.ContainsKey(property.PropertyType))
            {
                var method = TypeDeserializers[property.PropertyType];
                return((obj, context) => property.SetValue(obj, method.Invoke(obj, new[] { context }), null));
            }

            return(null);
        }