public bool TryAddPlayerFriends(PlayerFriends friends) { if (!ContainsPlayerFriends(friends.gameRefID)) { return(mCachedFriends.TryAdd(friends.gameRefID, new DbObjectWrapper <PlayerFriends> { Changed = true, Data = friends })); } return(false); }
public DbObjectWrapper <PlayerFriends> GetFriendsObject(string gameRefID, string login) { DbObjectWrapper <PlayerFriends> data = null; if (mCache.TryGetPlayerFriends(gameRefID, out data)) { return(data); } var dbFriends = application.DB.friends.FindOne(Query <PlayerFriends> .EQ(f => f.gameRefID, gameRefID)); if (dbFriends != null) { if (mCache.TryAddPlayerFriends(dbFriends)) { if (mCache.TryGetPlayerFriends(gameRefID, out data)) { return(data); } } } else { PlayerFriends newFriends = new PlayerFriends { gameRefID = gameRefID, login = login, friends = new Dictionary <string, Friend>() }; application.DB.friends.Save(newFriends); if (mCache.TryAddPlayerFriends(newFriends)) { if (mCache.TryGetPlayerFriends(gameRefID, out data)) { return(data); } } } data = null; return(null); }
public bool IsFriend(PlayerFriends other) { return(IsFriend(other.gameRefID)); }