Guest User

Untitled

a guest
Jan 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. public class Unit
  2. {
  3. public string Year { get; set; }
  4. public string Model { get; set; }
  5. }
  6.  
  7. {
  8. "UnitYear":"2018",
  9. "UnitModel":"F250 Super Duty"
  10. }
  11.  
  12. {
  13. "AssetYear":"2019",
  14. "AssetModel":"Corvette Stingray"
  15. }
  16.  
  17. Unit1 : Year = 2018, Model = F250 Super Duty
  18. Unit2 : Year = 2019, Model = Corvette Stingray
  19.  
  20. private static Dictionary<string, List<KeyValuePair<string, string>>> Units = new Dictionary<string, List<KeyValuePair<string,string>>>
  21. {
  22. { "0000001", new List<KeyValuePair<string,string>>
  23. {
  24. new KeyValuePair<string,string>("Year", "UnitYear"),
  25. new KeyValuePair<string,string>("Model", "UnitModel")
  26. }
  27. },
  28. { "0000002", new List<KeyValuePair<string,string>>
  29. {
  30. new KeyValuePair<string,string>("Year", "AssetYear"),
  31. new KeyValuePair<string,string>("Model", "AssetModel")
  32. }
  33. },
  34. };
  35.  
  36. Unit u1 = JsonConvert.DeserializeObject<Unit>(json, new GenericConverter("0000001"));
  37. Unit u2 = JsonConvert.DeserializeObject<Unit>(json, new GenericConverter("0000002"));
Add Comment
Please, Sign In to add comment