Guest User

Untitled

a guest
Nov 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
  2. {
  3. if (sourceType == typeof(string))
  4. {
  5. return true;
  6. }
  7.  
  8. return base.CanConvertFrom(context, sourceType);
  9. }
  10.  
  11. public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
  12. {
  13. if (value is string)
  14. {
  15. // parse the string, return a new node
  16. }
  17.  
  18. return base.ConvertFrom(context, culture, value);
  19. }
  20.  
  21. var str = "{"Username":"123","Name":"Test Name","Degree":0}";
  22. var deserialized = JsonConvert.DeserializeObject<Node>(str);
Add Comment
Please, Sign In to add comment