Example #1
0
 /// <summary>
 /// Unserializes the value int the specified instance.
 /// </summary>
 /// <param name="instance">The instance.</param>
 /// <param name="value">The value.</param>
 /// <exception cref="System.InvalidCastException"></exception>
 public void Unserialize(object instance, string value)
 {
     try
     {
         dynamic result = MyConverter.Unserialize(value, Type);
         SetValue(instance, result);
     }
     catch (Exception e)
     {
         throw new InvalidCastException(string.Format("invalid cast in the property '{0}'. The value '{1}' can't be casted in '{2}'", Name, value, Type.Name), e);
     }
 }
Example #2
0
 /// <summary>
 /// Serializes the specified member for instance.
 /// </summary>
 /// <param name="instance">The instance.</param>
 /// <returns></returns>
 public string Serialize(object instance)
 {
     return(MyConverter.Serialize(GetValue(instance)));
 }