private void AddFriend(Friend friend) { if (friendsList.Where(f => f.Name == friend.Name).FirstOrDefault() == null) { friendsList.Add(friend); } }
private Friend ensure(string who, int where) { var friend = friendsList.Where(f => f.Name == who).FirstOrDefault(); if (friend != null) return friend; var path = @"\Resources\" + who + ".png"; friend = new Friend { Name = who, Count = 0, Location = where, ImagePath = File.Exists(path) ? path : ANONYMOUS_PIC }; AddFriend(friend); return friend; }