Exemplo n.º 1
0
        private static int Compare(ServerEntry one, ServerEntry two)
        {
            switch( _sortType )
            {
                default:
                {
                    return int.Parse(one.Id).CompareTo(int.Parse(two.Id));
                }
                case SortType.Name:
                {
                    return one.Name.CompareTo(two.Name);
                }
                case SortType.Description:
                {
                    return one.Description.CompareTo(two.Description);
                }
                case SortType.Rank:
                {
                    return int.Parse(one.Rank).CompareTo(int.Parse(two.Rank));
                }
                case SortType.AvgOnline:
                {
                    return int.Parse(one.AvgOnline).CompareTo(int.Parse(two.AvgOnline)) * -1;
                }
                case SortType.CurOnline:
                {
                    return int.Parse(one.CurOnline).CompareTo(int.Parse(two.CurOnline)) * -1;
                }
                case SortType.MaxOnline:
                {
                    return int.Parse(one.MaxOnline).CompareTo(int.Parse(two.MaxOnline)) * -1;
                }
                case SortType.TotalVotes:
                {
                    return int.Parse(one.TotalVotes).CompareTo(int.Parse(two.TotalVotes)) * -1;
                }
                case SortType.Votes:
                {
                    return int.Parse(one.Votes).CompareTo(int.Parse(two.Votes)) * -1;
                }

            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves an array of server entries.
        /// </summary>
        /// <param name="page">page number</param>
        /// <param name="maxPerPage">maximum number displayed per page</param>
        /// <returns>Array of server entries</returns>
        public static ServerEntry[] GetServersByPage(int page, int maxPerPage)
        {
            int maxPages = _publicServerList.Count / maxPerPage;

            if (maxPages > page)
                return null;

            if (page > 0)
                page--;

            int index = page * maxPerPage;
            int max = Math.Min(_publicServerList.Count - index, maxPerPage);

            ServerEntry[] entries = new ServerEntry[max];
            _publicServerList.CopyTo(index, entries, 0, entries.Length);

            return entries;
        }