Guest User

Untitled

a guest
Mar 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. enum Tag
  2. {
  3. Name, Date, //There are many more
  4. }
  5.  
  6. class RequestDictionary : Dictionary<Tag, string>
  7. {
  8. }
  9.  
  10. enum Tag
  11. {
  12. Name, Date
  13. }
  14.  
  15. interface ITags
  16. {
  17. string Name { get; set; }
  18. DateTime Date { get; set; }
  19. }
  20.  
  21. class RequestDictionary : Dictionary<Tag, string>, ITags
  22. {
  23. public ITags Tags { get { return this; } }
  24.  
  25. string ITags.Name
  26. {
  27. get { return this[Tag.Name]; }
  28. set { this[Tag.Name] = value; }
  29. }
  30.  
  31. DateTime ITags.Date
  32. {
  33. get { return DateTime.ParseExact(this[Tag.Date], API_DATE_FORMAT, CultureInfo.InvariantCulture); }
  34. set { this[Tag.Name] = value.ToString(API_DATE_FORMAT); }
  35. }
  36. }
  37.  
  38. dict[Tag.Date] = DateTime.Now.ToString(API_DATE_FORMAT);
  39.  
  40. dict.Tags.Date = DateTime.Now;
  41.  
  42. var dict = new RequestDictionary
  43. {
  44. Tags.Date = DateTime.Now
  45. }
  46.  
  47. var dict = new RequestDictionary
  48. {
  49. { Tags.Date, DateTime.Now.ToString(API_DATE_FORMAT) }
  50. };
Add Comment
Please, Sign In to add comment