-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNeededDataCollection.cs
More file actions
43 lines (37 loc) · 1.18 KB
/
NeededDataCollection.cs
File metadata and controls
43 lines (37 loc) · 1.18 KB
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
using System.Collections.Generic;
using System.Linq;
using ZusiTcpInterface.TypeDescriptors;
namespace ZusiTcpInterface
{
public class NeededDataCollection
{
private readonly DescriptorCollection _descriptorCollection;
private readonly HashSet<AttributeDescriptor> _requestedDescriptors = new HashSet<AttributeDescriptor>();
public NeededDataCollection(DescriptorCollection descriptorCollection)
{
_descriptorCollection = descriptorCollection;
}
public void Request(params string[] namesOfAttributes)
{
foreach (string attributeName in namesOfAttributes)
{
_requestedDescriptors.Add(_descriptorCollection.GetBy(attributeName));
}
}
public void Request(params CabInfoAddress[] addressesOfAttributes)
{
foreach (var address in addressesOfAttributes)
{
_requestedDescriptors.Add(_descriptorCollection.GetBy(address));
}
}
public IEnumerable<AttributeDescriptor> GetRequestedDescriptors()
{
return _requestedDescriptors;
}
public IEnumerable<CabInfoAddress> GetRequestedAddresses()
{
return _requestedDescriptors.Select(descriptor => descriptor.Address);
}
}
}