forked from sbozzie/test-intel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntelChannelCollection.cs
More file actions
56 lines (54 loc) · 2.09 KB
/
Copy pathIntelChannelCollection.cs
File metadata and controls
56 lines (54 loc) · 2.09 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
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;
using System.Linq;
namespace PleaseIgnore.IntelMap {
/// <summary>
/// Specialization of <see cref="System.ComponentModel.ComponentCollection"/>
/// providing a list of <see cref="IntelChannel"/>.
/// </summary>
public class IntelChannelCollection : ReadOnlyCollection<IntelChannel> {
/// <summary>
/// Initializes a new instance of <see cref="IntelChannelCollection"/>.
/// </summary>
/// <param name="list">
/// The list to expose to the user.
/// </param>
/// <remarks>
/// <paramref name="list"/> is not copied by
/// <see cref="IntelChannelCollection(IList{IntelChannel})"/>, so
/// a synchronized copy must be made by the container.
/// </remarks>
public IntelChannelCollection(IList<IntelChannel> list)
: base(list) {
Contract.Requires<ArgumentNullException>(list != null, "list");
Contract.Requires<ArgumentException>(Contract.ForAll(list, x => x != null));
}
/// <summary>
/// Gets any <see cref="IntelChannel"/> monitoring the specified
/// channel.
/// </summary>
/// <param name="name">
/// The <see cref="IntelChannel.Name"/> to fetch.
/// </param>
/// <returns>
/// An instance of <see cref="IntelChannel"/> with the
/// <see cref="IntelChannel.Name"/> specified by
/// <paramref name="name"/> or <see langword="null"/> if
/// no such channel is being monitored.
/// </returns>
public IntelChannel this[string name] {
get {
if (name == null) {
return null;
} else {
return this.FirstOrDefault(x => String.Equals(
x.Name,
name,
StringComparison.OrdinalIgnoreCase));
}
}
}
}
}