StringDictionary.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. namespace System.Collections.Specialized
  2. {
  3. public class StringDictionary : IEnumerable
  4. {
  5. protected Hashtable table;
  6. public StringDictionary()
  7. {
  8. table = new Hashtable();
  9. }
  10. // Public Instance Properties
  11. public virtual int Count
  12. {
  13. get {
  14. return table.Count;
  15. }
  16. }
  17. public virtual bool IsSynchronized
  18. {
  19. get {
  20. return false;
  21. }
  22. }
  23. public virtual string this[string key]
  24. {
  25. get {
  26. return (string) table[key.ToLower()];
  27. }
  28. set {
  29. table[key.ToLower()] = value;
  30. }
  31. }
  32. public virtual ICollection Keys
  33. {
  34. get {
  35. return table.Keys;
  36. }
  37. }
  38. public virtual ICollection Values
  39. {
  40. get {
  41. return table.Values;
  42. }
  43. }
  44. public virtual object SyncRoot
  45. {
  46. get {
  47. return table.SyncRoot;
  48. }
  49. }
  50. // Public Instance Methods
  51. public virtual void Add(string key, string value)
  52. {
  53. table.Add(key.ToLower(), value);
  54. }
  55. public virtual void Clear()
  56. {
  57. table.Clear();
  58. }
  59. public virtual bool ContainsKey(string key)
  60. {
  61. return table.ContainsKey(key.ToLower());
  62. }
  63. public virtual bool ContainsValue(string value)
  64. {
  65. return table.ContainsValue(value);
  66. }
  67. public virtual void CopyTo(Array array, int index)
  68. {
  69. table.CopyTo(array, index);
  70. }
  71. public virtual IEnumerator GetEnumerator()
  72. {
  73. return table.GetEnumerator();
  74. }
  75. public virtual void Remove(string key)
  76. {
  77. table.Remove(key.ToLower());
  78. }
  79. }
  80. }