2 // System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection.cs
\r
5 // Tim Coleman (tim@timcoleman.com)
\r
7 // Copyright (C) Tim Coleman, 2002
\r
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Collections;
\r
32 using System.Web.Services;
\r
35 namespace System.Web.Services.Description {
\r
36 public sealed class ServiceDescriptionFormatExtensionCollection : ServiceDescriptionBaseCollection {
\r
38 #region Constructors
\r
40 public ServiceDescriptionFormatExtensionCollection (object parent)
\r
45 #endregion // Constructors
\r
49 public object this [int index] {
\r
51 if (index < 0 || index > Count)
\r
52 throw new ArgumentOutOfRangeException ();
\r
54 return List[index];
\r
56 set { List[index] = value; }
\r
59 #endregion // Properties
\r
63 public int Add (object extension)
\r
65 Insert (Count, extension);
\r
69 public bool Contains (object extension)
\r
71 return List.Contains (extension);
\r
74 public void CopyTo (object[] array, int index)
\r
76 List.CopyTo (array, index);
\r
79 public object Find (Type type)
\r
81 foreach (object value in List)
\r
82 if (type.IsAssignableFrom (value.GetType ()))
\r
87 public XmlElement Find (string name, string ns)
\r
89 XmlElement xmlElement;
\r
90 foreach (object value in List)
\r
91 if (value is XmlElement) {
\r
92 xmlElement = (value as XmlElement);
\r
93 if (xmlElement.Name == name && xmlElement.NamespaceURI == ns)
\r
99 public object[] FindAll (Type type)
\r
101 ArrayList searchResults = new ArrayList ();
\r
102 foreach (object value in List)
\r
103 if (value.GetType () == type)
\r
104 searchResults.Add (value);
\r
105 object[] returnValue = new object [searchResults.Count];
\r
107 if (searchResults.Count > 0)
\r
108 searchResults.CopyTo (returnValue);
\r
110 return returnValue;
\r
113 public XmlElement[] FindAll (string name, string ns)
\r
115 ArrayList searchResults = new ArrayList ();
\r
116 XmlElement xmlElement;
\r
118 foreach (object value in List)
\r
119 if (value is XmlElement) {
\r
120 xmlElement = (value as XmlElement);
\r
121 if (xmlElement.Name == name && xmlElement.NamespaceURI == ns)
\r
122 searchResults.Add (xmlElement);
\r
125 XmlElement[] returnValue = new XmlElement [searchResults.Count];
\r
127 if (searchResults.Count > 0)
\r
128 searchResults.CopyTo (returnValue);
\r
130 return returnValue;
\r
133 public int IndexOf (object extension)
\r
135 return List.IndexOf (extension);
\r
138 public void Insert (int index, object extension)
\r
140 List.Insert (index, extension);
\r
144 public bool IsHandled (object item)
\r
146 throw new NotImplementedException ();
\r
150 public bool IsRequired (object item)
\r
152 throw new NotImplementedException ();
\r
155 protected override void OnValidate (object value)
\r
158 throw new ArgumentNullException ();
\r
159 if (!(value is XmlElement || value is ServiceDescriptionFormatExtension))
\r
160 throw new ArgumentException ();
\r
163 public void Remove (object extension)
\r
165 List.Remove (extension);
\r
168 protected override void SetParent (object value, object parent)
\r
170 ((ServiceDescriptionFormatExtension) value).SetParent (parent);
\r
173 #endregion // Methods
\r