StringDictionary.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // System.Collections.Specialized.StringDictionary.cs
  3. //
  4. // Author:
  5. // Andreas Nahr ([email protected])
  6. //
  7. // (C) Ximian, Inc. http://www.ximian.com
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System.ComponentModel.Design.Serialization;
  30. namespace System.Collections.Specialized
  31. {
  32. [DesignerSerializer ("System.Diagnostics.Design.StringDictionaryCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
  33. public class StringDictionary : IEnumerable
  34. {
  35. private Hashtable table;
  36. public StringDictionary()
  37. {
  38. table = new Hashtable();
  39. }
  40. // Public Instance Properties
  41. public virtual int Count
  42. {
  43. get {
  44. return table.Count;
  45. }
  46. }
  47. public virtual bool IsSynchronized
  48. {
  49. get {
  50. return false;
  51. }
  52. }
  53. public virtual string this[string key]
  54. {
  55. get {
  56. return (string) table[key.ToLower()];
  57. }
  58. set {
  59. table[key.ToLower()] = value;
  60. }
  61. }
  62. public virtual ICollection Keys
  63. {
  64. get {
  65. return table.Keys;
  66. }
  67. }
  68. public virtual ICollection Values
  69. {
  70. get {
  71. return table.Values;
  72. }
  73. }
  74. public virtual object SyncRoot
  75. {
  76. get {
  77. return table.SyncRoot;
  78. }
  79. }
  80. // Public Instance Methods
  81. public virtual void Add(string key, string value)
  82. {
  83. table.Add(key.ToLower(), value);
  84. }
  85. public virtual void Clear()
  86. {
  87. table.Clear();
  88. }
  89. public virtual bool ContainsKey(string key)
  90. {
  91. return table.ContainsKey(key.ToLower());
  92. }
  93. public virtual bool ContainsValue(string value)
  94. {
  95. return table.ContainsValue(value);
  96. }
  97. public virtual void CopyTo(Array array, int index)
  98. {
  99. table.CopyTo(array, index);
  100. }
  101. public virtual IEnumerator GetEnumerator()
  102. {
  103. return table.GetEnumerator();
  104. }
  105. public virtual void Remove(string key)
  106. {
  107. table.Remove(key.ToLower());
  108. }
  109. }
  110. }