ConfigurationPropertyCollection.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // System.Configuration.ConfigurationPropertyCollection.cs
  3. //
  4. // Authors:
  5. // Duncan Mak ([email protected])
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining
  8. // a copy of this software and associated documentation files (the
  9. // "Software"), to deal in the Software without restriction, including
  10. // without limitation the rights to use, copy, modify, merge, publish,
  11. // distribute, sublicense, and/or sell copies of the Software, and to
  12. // permit persons to whom the Software is furnished to do so, subject to
  13. // the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be
  16. // included in all copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  22. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  23. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  24. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. //
  26. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  27. //
  28. #if NET_2_0
  29. using System;
  30. using System.Collections;
  31. using System.Collections.Generic;
  32. namespace System.Configuration
  33. {
  34. public class ConfigurationPropertyCollection : ICollection, IEnumerable
  35. {
  36. List <ConfigurationProperty> collection;
  37. public ConfigurationPropertyCollection ()
  38. {
  39. collection = new List <ConfigurationProperty> ();
  40. }
  41. public int Count {
  42. get { return collection.Count; }
  43. }
  44. public ConfigurationProperty this [string name] {
  45. get {
  46. foreach (ConfigurationProperty cp in collection)
  47. if (cp.Name == name)
  48. return cp;
  49. return null;
  50. }
  51. }
  52. public bool IsSynchronized {
  53. get { return false; }
  54. }
  55. public object SyncRoot {
  56. get { return collection; }
  57. }
  58. public void Add (ConfigurationProperty property)
  59. {
  60. collection.Add (property);
  61. }
  62. public bool Contains (string name)
  63. {
  64. ConfigurationProperty property = this [name];
  65. if (property == null)
  66. return false;
  67. return collection.Contains (property);
  68. }
  69. public void CopyTo (ConfigurationProperty [] array, int index)
  70. {
  71. collection.CopyTo (array, index);
  72. }
  73. void ICollection.CopyTo (Array array, int index)
  74. {
  75. ((ICollection) collection).CopyTo (array, index);
  76. }
  77. public IEnumerator GetEnumerator ()
  78. {
  79. return collection.GetEnumerator ();
  80. }
  81. public bool Remove (string name)
  82. {
  83. return collection.Remove (this [name]);
  84. }
  85. public void Clear ()
  86. {
  87. collection.Clear ();
  88. }
  89. }
  90. }
  91. #endif