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