-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathUrlList.cs
40 lines (33 loc) · 873 Bytes
/
UrlList.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
using System.Collections.Generic;
namespace WebScreenSaver
{
internal class UrlList
{
private const string DefaultUrl = "http://whatthecommit.com/";
private int _listIndex;
private List<string> _urlList = new List<string>();
public UrlList()
{
}
public UrlList(IEnumerable<string> urls)
{
Assign(urls);
}
public string GetNext()
{
if (_listIndex >= _urlList.Count)
_listIndex = 0;
return _urlList[_listIndex++];
}
public void Add(string url)
{
_urlList.Add(url);
}
public void Assign(IEnumerable<string> urls)
{
_urlList = new List<string>(urls);
if (_urlList.Count == 0)
_urlList.Add(DefaultUrl);
}
}
}