-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathProxyList.cs
63 lines (56 loc) · 1.44 KB
/
ProxyList.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using AdvancedBot.client;
using AdvancedBot.ProxyChecker;
namespace AdvancedBot
{
public class ProxyList : IEnumerable<ProxyInfo>
{
public List<ProxyInfo> _list = new List<ProxyInfo>();
private int index;
public int Count { get { return _list.Count; } }
public void Add(ProxyInfo proxy)
{
_list.Add(proxy);
}
public void AddRange(IEnumerable<ProxyInfo> _enum)
{
_list.AddRange(_enum);
}
public bool HasAny() { return _list.Count > 0; }
public ProxyInfo Next()
{
return _list[index++ % _list.Count];
}
public Proxy NextProxy()
{
int count = _list.Count;
if (count > 0) {
ProxyInfo p = _list[index++ % count];
return new Proxy(p.IP, p.Port, p.Type);
} else {
return null;
}
}
public void Clear()
{
_list.Clear();
index = 0;
}
public void ResetIndexes()
{
index = 0;
}
public IEnumerator<ProxyInfo> GetEnumerator()
{
return _list.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _list.GetEnumerator();
}
}
}