public BuddyGroup[] GetAllBuddyInGroup(string username) { var buddies = GetAllBuddy(username); Dictionary <string, BuddyGroup> groups = new Dictionary <string, BuddyGroup>(); foreach (var item in buddies) { BuddyGroup group; if (!groups.TryGetValue(item.GroupName, out group)) { group = new BuddyGroup(); group.GroupName = item.GroupName; groups.Add(group.GroupName, group); group.User = username; } group.Buddies.Add(item); } return(groups.Values.ToArray()); }
private void AddBuddyGroup(BuddyGroup group) { lock (Groups) { lock (Roster) { BuddyGroup destGroup = group; for (int i = 0; i < Groups.Count; i++) { if (group.GroupName == Groups[i].GroupName) { destGroup = Groups[i]; break; } } foreach (var item in group.Buddies) { destGroup.Buddies.Add(item); Roster.AddRosterItem( new Xmpp.Roster.RosterItem(item.Username, item.Nickname, destGroup.GroupName)); } } } }
public BuddyGroup[] GetAllBuddyInGroup(string username) { var buddies = GetAllBuddy(username); Dictionary<string, BuddyGroup> groups = new Dictionary<string, BuddyGroup>(); foreach (var item in buddies) { BuddyGroup group; if (!groups.TryGetValue(item.GroupName, out group)) { group = new BuddyGroup(); group.GroupName = item.GroupName; groups.Add(group.GroupName, group); group.User = username; } group.Buddies.Add(item); } return groups.Values.ToArray(); }