Ejemplo n.º 1
0
        public static IEnumerable <BubbleGroup> SortByMostPopular(Service service,
                                                                  bool avoidParties = true)
        {
            foreach (var mostPopularBubbleGroupLocation in
                     Directory.EnumerateFiles(BubbleGroupDatabase.GetServiceLocation(service.Information))
                     .OrderByDescending(x => new FileInfo(x).Length))
            {
                var groupHeader    = Path.GetFileNameWithoutExtension(mostPopularBubbleGroupLocation);
                var groupDelimeter = groupHeader.IndexOf("^", StringComparison.Ordinal);
                var groupId        = groupHeader.Substring(groupDelimeter + 1);
                lock (BubbleGroupsLock)
                {
                    foreach (var group in BubbleGroups.Where(x => x.Service == service))
                    {
                        if (@group.ID == groupId)
                        {
                            if (avoidParties && @group.IsParty)
                            {
                                break;
                            }

                            yield return(@group);
                        }
                    }
                }
            }
        }