|
- using System;
- using System.Collections.Generic;
- using SUISS.Storage;
-
- namespace SUISS.Cloud
- {
- public class Friend : IFriend, IStorable
- {
- public Friend(string accountUuid, string friendName, IDictionary<string, GameInfo> games)
- {
- this.AccountUuid = accountUuid;
- this.FriendName = friendName;
- this._games = games;
- }
-
- public Friend()
- {
- }
-
- public string AccountUuid { get; private set; }
-
- public string FriendName { get; private set; }
-
- public IList<string> GameUuids
- {
- get
- {
- return new List<string>(this._games.Keys);
- }
- }
-
- public IGameInfo GameData(string gameUuid)
- {
- return this._games[gameUuid];
- }
-
- public void FromStorage(IDictionary<string, object> dict)
- {
- this.AccountUuid = (string)dict["accountUuid"];
- this.FriendName = (string)dict["friendName"];
- Dictionary<string, object> dictionary;
- if (dict.ContainsKey("gameData"))
- {
- dictionary = (Dictionary<string, object>)dict["gameData"];
- }
- else
- {
- dictionary = new Dictionary<string, object>();
- }
- this._games = new Dictionary<string, GameInfo>();
- foreach (KeyValuePair<string, object> keyValuePair in dictionary)
- {
- this._games.Add(keyValuePair.Key, (GameInfo)keyValuePair.Value);
- }
- }
-
- public IDictionary<string, object> ToStorage()
- {
- Dictionary<string, object> dictionary = new Dictionary<string, object>();
- foreach (KeyValuePair<string, GameInfo> keyValuePair in this._games)
- {
- dictionary.Add(keyValuePair.Key, keyValuePair.Value);
- }
- return new Dictionary<string, object>
- {
- {
- "accountUuid",
- this.AccountUuid
- },
- {
- "friendName",
- this.FriendName
- },
- {
- "gameData ",
- dictionary
- }
- };
- }
-
- private IDictionary<string, GameInfo> _games;
- }
- }
|