ServiceDescriptionFormatExtensionCollection.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. //
  2. // System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  8. //
  9. using System.Collections;
  10. using System.Web.Services;
  11. using System.Xml;
  12. namespace System.Web.Services.Description {
  13. public sealed class ServiceDescriptionFormatExtensionCollection : ServiceDescriptionBaseCollection {
  14. #region Constructors
  15. public ServiceDescriptionFormatExtensionCollection (object parent)
  16. : base (parent)
  17. {
  18. }
  19. #endregion // Constructors
  20. #region Properties
  21. public object this [int index] {
  22. get {
  23. if (index < 0 || index > Count)
  24. throw new ArgumentOutOfRangeException ();
  25. return List[index];
  26. }
  27. set { List[index] = value; }
  28. }
  29. #endregion // Properties
  30. #region Methods
  31. public int Add (object extension)
  32. {
  33. Insert (Count, extension);
  34. return (Count - 1);
  35. }
  36. public bool Contains (object extension)
  37. {
  38. return List.Contains (extension);
  39. }
  40. public void CopyTo (object[] array, int index)
  41. {
  42. List.CopyTo (array, index);
  43. }
  44. public object Find (Type type)
  45. {
  46. foreach (object value in List)
  47. if (value.GetType () == type)
  48. return value;
  49. return null;
  50. }
  51. public XmlElement Find (string name, string ns)
  52. {
  53. XmlElement xmlElement;
  54. foreach (object value in List)
  55. if (value is XmlElement) {
  56. xmlElement = (value as XmlElement);
  57. if (xmlElement.Name == name && xmlElement.NamespaceURI == ns)
  58. return xmlElement;
  59. }
  60. return null;
  61. }
  62. public object[] FindAll (Type type)
  63. {
  64. ArrayList searchResults = new ArrayList ();
  65. foreach (object value in List)
  66. if (value.GetType () == type)
  67. searchResults.Add (value);
  68. object[] returnValue = new object [searchResults.Count];
  69. if (searchResults.Count > 0)
  70. searchResults.CopyTo (returnValue);
  71. return returnValue;
  72. }
  73. public XmlElement[] FindAll (string name, string ns)
  74. {
  75. ArrayList searchResults = new ArrayList ();
  76. XmlElement xmlElement;
  77. foreach (object value in List)
  78. if (value is XmlElement) {
  79. xmlElement = (value as XmlElement);
  80. if (xmlElement.Name == name && xmlElement.NamespaceURI == ns)
  81. searchResults.Add (xmlElement);
  82. }
  83. XmlElement[] returnValue = new XmlElement [searchResults.Count];
  84. if (searchResults.Count > 0)
  85. searchResults.CopyTo (returnValue);
  86. return returnValue;
  87. }
  88. public int IndexOf (object extension)
  89. {
  90. return List.IndexOf (extension);
  91. }
  92. public void Insert (int index, object extension)
  93. {
  94. List.Insert (index, extension);
  95. }
  96. [MonoTODO]
  97. public bool IsHandled (object item)
  98. {
  99. throw new NotImplementedException ();
  100. }
  101. [MonoTODO]
  102. public bool IsRequired (object item)
  103. {
  104. throw new NotImplementedException ();
  105. }
  106. protected override void OnValidate (object value)
  107. {
  108. if (value == null)
  109. throw new ArgumentNullException ();
  110. if (!(value is XmlElement || value is ServiceDescriptionFormatExtension))
  111. throw new ArgumentException ();
  112. }
  113. public void Remove (object extension)
  114. {
  115. List.Remove (extension);
  116. }
  117. protected override void SetParent (object value, object parent)
  118. {
  119. ((ServiceDescriptionFormatExtension) value).SetParent (parent);
  120. }
  121. #endregion // Methods
  122. }
  123. }