PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescriptionFormatExtensionCollection.cs

https://bitbucket.org/danipen/mono
C# | 178 lines | 118 code | 32 blank | 28 comment | 22 complexity | a17ff8edbb2249d52961f3c06baac145 MD5 | raw file
Possible License(s): Unlicense, Apache-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0
  1. //
  2. // System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection.cs
  3. //
  4. // Author:
  5. // Tim Coleman (tim@timcoleman.com)
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  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.Collections;
  30. using System.Web.Services;
  31. using System.Xml;
  32. namespace System.Web.Services.Description {
  33. public sealed class ServiceDescriptionFormatExtensionCollection : ServiceDescriptionBaseCollection {
  34. #region Constructors
  35. public ServiceDescriptionFormatExtensionCollection (object parent)
  36. : base (parent)
  37. {
  38. }
  39. #endregion // Constructors
  40. #region Properties
  41. public object this [int index] {
  42. get {
  43. if (index < 0 || index > Count)
  44. throw new ArgumentOutOfRangeException ();
  45. return List[index];
  46. }
  47. set { List[index] = value; }
  48. }
  49. #endregion // Properties
  50. #region Methods
  51. public int Add (object extension)
  52. {
  53. Insert (Count, extension);
  54. return (Count - 1);
  55. }
  56. public bool Contains (object extension)
  57. {
  58. return List.Contains (extension);
  59. }
  60. public void CopyTo (object[] array, int index)
  61. {
  62. List.CopyTo (array, index);
  63. }
  64. public object Find (Type type)
  65. {
  66. foreach (object value in List)
  67. if (type.IsInstanceOfType (value))
  68. return value;
  69. return null;
  70. }
  71. public XmlElement Find (string name, string ns)
  72. {
  73. XmlElement xmlElement;
  74. foreach (object value in List)
  75. if (value is XmlElement) {
  76. xmlElement = (value as XmlElement);
  77. if (xmlElement.Name == name && xmlElement.NamespaceURI == ns)
  78. return xmlElement;
  79. }
  80. return null;
  81. }
  82. public object[] FindAll (Type type)
  83. {
  84. ArrayList searchResults = new ArrayList ();
  85. foreach (object value in List)
  86. if (type.IsInstanceOfType(value))
  87. searchResults.Add (value);
  88. object[] returnValue = new object [searchResults.Count];
  89. if (searchResults.Count > 0)
  90. searchResults.CopyTo (returnValue);
  91. return returnValue;
  92. }
  93. public XmlElement[] FindAll (string name, string ns)
  94. {
  95. ArrayList searchResults = new ArrayList ();
  96. XmlElement xmlElement;
  97. foreach (object value in List)
  98. if (value is XmlElement) {
  99. xmlElement = (value as XmlElement);
  100. if (xmlElement.Name == name && xmlElement.NamespaceURI == ns)
  101. searchResults.Add (xmlElement);
  102. }
  103. XmlElement[] returnValue = new XmlElement [searchResults.Count];
  104. if (searchResults.Count > 0)
  105. searchResults.CopyTo (returnValue);
  106. return returnValue;
  107. }
  108. public int IndexOf (object extension)
  109. {
  110. return List.IndexOf (extension);
  111. }
  112. public void Insert (int index, object extension)
  113. {
  114. List.Insert (index, extension);
  115. }
  116. [MonoTODO]
  117. public bool IsHandled (object item)
  118. {
  119. throw new NotImplementedException ();
  120. }
  121. [MonoTODO]
  122. public bool IsRequired (object item)
  123. {
  124. throw new NotImplementedException ();
  125. }
  126. protected override void OnValidate (object value)
  127. {
  128. if (value == null)
  129. throw new ArgumentNullException ();
  130. if (!(value is XmlElement || value is ServiceDescriptionFormatExtension))
  131. throw new ArgumentException ();
  132. }
  133. public void Remove (object extension)
  134. {
  135. List.Remove (extension);
  136. }
  137. protected override void SetParent (object value, object parent)
  138. {
  139. ServiceDescriptionFormatExtension extension = value as ServiceDescriptionFormatExtension;
  140. if (extension == null)
  141. return;
  142. extension.SetParent (parent);
  143. }
  144. #endregion // Methods
  145. }
  146. }