You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

84 lines
1.8 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using SUISS.Storage;
  4. namespace SUISS.Cloud
  5. {
  6. public class Friend : IFriend, IStorable
  7. {
  8. public Friend(string accountUuid, string friendName, IDictionary<string, GameInfo> games)
  9. {
  10. this.AccountUuid = accountUuid;
  11. this.FriendName = friendName;
  12. this._games = games;
  13. }
  14. public Friend()
  15. {
  16. }
  17. public string AccountUuid { get; private set; }
  18. public string FriendName { get; private set; }
  19. public IList<string> GameUuids
  20. {
  21. get
  22. {
  23. return new List<string>(this._games.Keys);
  24. }
  25. }
  26. public IGameInfo GameData(string gameUuid)
  27. {
  28. return this._games[gameUuid];
  29. }
  30. public void FromStorage(IDictionary<string, object> dict)
  31. {
  32. this.AccountUuid = (string)dict["accountUuid"];
  33. this.FriendName = (string)dict["friendName"];
  34. Dictionary<string, object> dictionary;
  35. if (dict.ContainsKey("gameData"))
  36. {
  37. dictionary = (Dictionary<string, object>)dict["gameData"];
  38. }
  39. else
  40. {
  41. dictionary = new Dictionary<string, object>();
  42. }
  43. this._games = new Dictionary<string, GameInfo>();
  44. foreach (KeyValuePair<string, object> keyValuePair in dictionary)
  45. {
  46. this._games.Add(keyValuePair.Key, (GameInfo)keyValuePair.Value);
  47. }
  48. }
  49. public IDictionary<string, object> ToStorage()
  50. {
  51. Dictionary<string, object> dictionary = new Dictionary<string, object>();
  52. foreach (KeyValuePair<string, GameInfo> keyValuePair in this._games)
  53. {
  54. dictionary.Add(keyValuePair.Key, keyValuePair.Value);
  55. }
  56. return new Dictionary<string, object>
  57. {
  58. {
  59. "accountUuid",
  60. this.AccountUuid
  61. },
  62. {
  63. "friendName",
  64. this.FriendName
  65. },
  66. {
  67. "gameData ",
  68. dictionary
  69. }
  70. };
  71. }
  72. private IDictionary<string, GameInfo> _games;
  73. }
  74. }