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());
        }
예제 #2
0
 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));
             }
         }
     }
 }
예제 #3
0
 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();
 }