InstanceDataCollection.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // System.Diagnostics.InstanceDataCollection.cs
  3. //
  4. // Authors:
  5. // Jonathan Pryor ([email protected])
  6. //
  7. // (C) 2002
  8. //
  9. using System;
  10. using System.Collections;
  11. using System.Diagnostics;
  12. namespace System.Diagnostics {
  13. public class InstanceDataCollection : DictionaryBase {
  14. private string counterName;
  15. private static void CheckNull (object value, string name)
  16. {
  17. if (value == null)
  18. throw new ArgumentNullException (name);
  19. }
  20. // may throw ArgumentNullException
  21. public InstanceDataCollection (string counterName)
  22. {
  23. CheckNull (counterName, "counterName");
  24. this.counterName = counterName;
  25. }
  26. public string CounterName {
  27. get {return counterName;}
  28. }
  29. // may throw ArgumentNullException
  30. public InstanceData this [string instanceName] {
  31. get {
  32. CheckNull (instanceName, "instanceName");
  33. return (InstanceData) Dictionary [instanceName];
  34. }
  35. }
  36. public ICollection Keys {
  37. get {return Dictionary.Keys;}
  38. }
  39. public ICollection Values {
  40. get {return Dictionary.Values;}
  41. }
  42. // may throw ArgumentNullException
  43. public bool Contains (string instanceName)
  44. {
  45. CheckNull (instanceName, "instanceName");
  46. return Dictionary.Contains (instanceName);
  47. }
  48. public void CopyTo (InstanceData[] instances, int index)
  49. {
  50. Dictionary.CopyTo (instances, index);
  51. }
  52. }
  53. }