-
Notifications
You must be signed in to change notification settings - Fork 0
/
[PA 4] RobotsReader.cs
52 lines (46 loc) · 1.27 KB
/
[PA 4] RobotsReader.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkerRole1
{
class RobotsReader
{
private Dictionary<string, Robots> robotParsers = new Dictionary<string, Robots>();
public RobotsReader() { }
public void addParser(string authority)
{
robotParsers[authority] = new Robots(authority);
}
public HashSet<string> getAllDisallowed()
{
HashSet<string> disallowed = new HashSet<string>();
foreach (Robots parser in robotParsers.Values)
{
disallowed.UnionWith(parser.getDisallowed());
}
return disallowed;
}
public HashSet<string> getAllLinks()
{
HashSet<string> links = new HashSet<string>();
foreach (Robots parser in robotParsers.Values)
{
links.UnionWith(parser.getLinks());
}
return links;
}
public Robots getParser(string authority)
{
try
{
return robotParsers[authority];
}
catch (KeyNotFoundException)
{
return null;
}
}
}
}