/
InstanceDataCollectionCollection.cs
65 lines (55 loc) · 2.24 KB
/
InstanceDataCollectionCollection.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
64
65
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections;
using System.Globalization;
namespace System.Diagnostics
{
/// <summary>
/// The collection returned from the <see cref='System.Diagnostics.PerformanceCounterCategory.ReadCategory'/> method.
/// that contains all the counter and instance data.
/// The collection contains an InstanceDataCollection object for each counter. Each InstanceDataCollection
/// object contains the performance data for all counters for that instance. In other words the data is
/// indexed by counter name and then by instance name.
/// </summary>
public class InstanceDataCollectionCollection : DictionaryBase
{
[Obsolete("This constructor has been deprecated. Use System.Diagnostics.PerformanceCounterCategory.ReadCategory() to get an instance of this collection instead.")]
public InstanceDataCollectionCollection() : base() { }
public InstanceDataCollection this[string counterName]
{
get
{
if (counterName == null)
throw new ArgumentNullException(nameof(counterName));
object objectName = counterName.ToLowerInvariant();
return (InstanceDataCollection)Dictionary[objectName];
}
}
public ICollection Keys
{
get { return Dictionary.Keys; }
}
public ICollection Values
{
get
{
return Dictionary.Values;
}
}
internal void Add(string counterName, InstanceDataCollection value)
{
object objectName = counterName.ToLowerInvariant();
Dictionary.Add(objectName, value);
}
public bool Contains(string counterName)
{
ArgumentNullException.ThrowIfNull(counterName);
object objectName = counterName.ToLowerInvariant();
return Dictionary.Contains(objectName);
}
public void CopyTo(InstanceDataCollection[] counters, int index)
{
Dictionary.Values.CopyTo((Array)counters, index);
}
}
}