Пример #1
0
        /// <summary>
        /// 获取ip信息列表
        /// </summary>
        /// <param name="url">获取IP的地址</param>
        /// <param name="sort">排序方式</param>
        /// <returns>返回List<Object_IP></returns>
        public void GetSourceList(Action <List <Object_IP> > callback, string url, SortOrder sort = SortOrder.Ascending)
        {
            List <Object_IP> list = GetIPList.GetSourceList(url);

            Parallel.ForEach(list, (item) =>
            {
                item.HttpSetSpeed();
            });
            switch (sort)
            {
            case SortOrder.Ascending:
            {
                list.Sort(CompareSpeedAsc);
                break;
            }

            case SortOrder.Descending:
            {
                list.Sort(CompareSpeedDesc);
                break;
            }

            case SortOrder.Unspecified:
            {
                break;
            }
            }
            list = list.Where(item => item.Speed != null && !item.Ip.StartsWith("127")).Select(x => x).ToList <Object_IP>();
            callback(list);
        }
Пример #2
0
        /// <summary>
        /// 逐条返回信息
        /// </summary>
        /// <param name="callback">返回的Object_IP对象</param>
        /// <param name="url">获取信息的URL</param>
        public void GetSourceItem(Action <Object_IP> callback, string url)
        {
            var list = GetIPList.GetSourceList(url);

            Parallel.ForEach(list, (item) =>
            {
                item.HttpSetSpeed();
                callback(item);
            });
        }