public static IEnumerable<Tweet> GetTweetsForUser(User user, ILookup<string, Tweet> tweets) { var result = new List<Tweet>(); result.AddRange(tweets[user.Name.ToUpper()]); foreach (var follow in user.Follows) { result.AddRange(tweets[follow.Name.ToUpper()]); } return result.OrderBy(p => p.Sequence); }
public static User GetOrCreateUser(string name, Dictionary<string, User> existing) { User find = null; string upperTest = name.ToUpper(); if (existing.TryGetValue(upperTest, out find) == false) { find = new User(name); existing.Add(upperTest, find); } return find; }