25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

66 lines
1.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using SUISS.Cloud.Extensions;
  4. using SUISS.Storage;
  5. namespace SUISS.Cloud
  6. {
  7. public class Gift : IGift, IStorable
  8. {
  9. public Gift(string id, string senderName, string type, long amount)
  10. {
  11. this.GiftId = id;
  12. this.SenderName = senderName;
  13. this.Type = type;
  14. this.Amount = amount;
  15. }
  16. public string GiftId { get; private set; }
  17. public string SenderName { get; private set; }
  18. public string Type { get; private set; }
  19. public long Amount { get; private set; }
  20. public void FromStorage(IDictionary<string, object> dict)
  21. {
  22. this.GiftId = dict.GetString("id", string.Empty);
  23. this.SenderName = dict.GetString("senderName", string.Empty);
  24. this.Type = dict.GetString("type", string.Empty);
  25. this.Amount = dict.GetLong("amount", 0L);
  26. }
  27. public IDictionary<string, object> ToStorage()
  28. {
  29. return new Dictionary<string, object>
  30. {
  31. {
  32. "id",
  33. this.GiftId
  34. },
  35. {
  36. "senderName",
  37. this.SenderName
  38. },
  39. {
  40. "type",
  41. this.Type
  42. },
  43. {
  44. "amount",
  45. this.Amount
  46. }
  47. };
  48. }
  49. private const string IdKey = "id";
  50. private const string SenderNameKey = "senderName";
  51. private const string TypeKey = "type";
  52. private const string AmountKey = "amount";
  53. }
  54. }