Initial commit
[mono.git] / mcs / class / referencesource / System / services / monitoring / system / diagnosticts / InstanceDataCollectionCollection.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="InstanceDataCollectionCollection.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>                                                                
5 //------------------------------------------------------------------------------
6
7 namespace System.Diagnostics {
8
9     using System.Diagnostics;
10     using System;
11     using System.Collections;
12     using System.Globalization;
13     
14     /// <devdoc>
15     ///     The collection returned from  the <see cref='System.Diagnostics.PerformanceCounterCategory.ReadCategory'/> method.  
16     ///     that contains all the counter and instance data.
17     ///     The collection contains an InstanceDataCollection object for each counter.  Each InstanceDataCollection
18     ///     object contains the performance data for all counters for that instance.  In other words the data is
19     ///     indexed by counter name and then by instance name.
20     /// </devdoc>    
21     public class InstanceDataCollectionCollection : DictionaryBase {
22
23     
24         [Obsolete("This constructor has been deprecated.  Please use System.Diagnostics.PerformanceCounterCategory.ReadCategory() to get an instance of this collection instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
25         public InstanceDataCollectionCollection() : base() {}
26         
27         /// <devdoc>
28         ///    <para>[To be supplied.]</para>
29         /// </devdoc>
30         public InstanceDataCollection this[string counterName] {
31             get {
32                 if (counterName == null)
33                     throw new ArgumentNullException("counterName");
34                     
35                 object objectName = counterName.ToLower(CultureInfo.InvariantCulture);
36                 return (InstanceDataCollection) Dictionary[objectName];
37             }
38         }
39
40         /// <devdoc>
41         ///    <para>[To be supplied.]</para>
42         /// </devdoc>
43         public ICollection Keys {
44             get { return Dictionary.Keys; }
45         }
46
47         /// <devdoc>
48         ///    <para>[To be supplied.]</para>
49         /// </devdoc>
50         public ICollection Values {
51             get {
52                 return Dictionary.Values;
53             }
54         }
55
56         internal void Add(string counterName, InstanceDataCollection value) {
57             object objectName = counterName.ToLower(CultureInfo.InvariantCulture); 
58             Dictionary.Add(objectName, value);
59         }
60
61         /// <devdoc>
62         ///    <para>[To be supplied.]</para>
63         /// </devdoc>
64         public bool Contains(string counterName) {    
65             if (counterName == null)
66                     throw new ArgumentNullException("counterName");
67                     
68             object objectName = counterName.ToLower(CultureInfo.InvariantCulture);
69             return Dictionary.Contains(objectName);
70         }
71         
72         /// <devdoc>
73         ///    <para>[To be supplied.]</para>
74         /// </devdoc>
75         public void CopyTo(InstanceDataCollection[] counters, int index) {
76             Dictionary.Values.CopyTo((Array)counters, index);
77         }
78     }
79 }