2 // System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection.cs
5 // Tim Coleman (tim@timcoleman.com)
7 // Copyright (C) Tim Coleman, 2002
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
;
32 using System
.Web
.Services
;
35 namespace System
.Web
.Services
.Description
{
36 public sealed class ServiceDescriptionFormatExtensionCollection
: ServiceDescriptionBaseCollection
{
40 public ServiceDescriptionFormatExtensionCollection (object parent
)
45 #endregion // Constructors
49 public object this [int index
] {
51 if (index
< 0 || index
> Count
)
52 throw new ArgumentOutOfRangeException ();
56 set { List[index] = value; }
59 #endregion // Properties
63 public int Add (object extension
)
65 Insert (Count
, extension
);
69 public bool Contains (object extension
)
71 return List
.Contains (extension
);
74 public void CopyTo (object[] array
, int index
)
76 List
.CopyTo (array
, index
);
79 public object Find (Type type
)
81 foreach (object value in List
)
82 if (type
.IsInstanceOfType (value))
87 public XmlElement
Find (string name
, string ns
)
89 XmlElement xmlElement
;
90 foreach (object value in List
)
91 if (value is XmlElement
) {
92 xmlElement
= (value as XmlElement
);
93 if (xmlElement
.Name
== name
&& xmlElement
.NamespaceURI
== ns
)
99 public object[] FindAll (Type type
)
101 ArrayList searchResults
= new ArrayList ();
102 foreach (object value in List
)
103 if (type
.IsInstanceOfType(value))
104 searchResults
.Add (value);
105 object[] returnValue
= new object [searchResults
.Count
];
107 if (searchResults
.Count
> 0)
108 searchResults
.CopyTo (returnValue
);
113 public XmlElement
[] FindAll (string name
, string ns
)
115 ArrayList searchResults
= new ArrayList ();
116 XmlElement xmlElement
;
118 foreach (object value in List
)
119 if (value is XmlElement
) {
120 xmlElement
= (value as XmlElement
);
121 if (xmlElement
.Name
== name
&& xmlElement
.NamespaceURI
== ns
)
122 searchResults
.Add (xmlElement
);
125 XmlElement
[] returnValue
= new XmlElement
[searchResults
.Count
];
127 if (searchResults
.Count
> 0)
128 searchResults
.CopyTo (returnValue
);
133 public int IndexOf (object extension
)
135 return List
.IndexOf (extension
);
138 public void Insert (int index
, object extension
)
140 List
.Insert (index
, extension
);
144 public bool IsHandled (object item
)
146 throw new NotImplementedException ();
150 public bool IsRequired (object item
)
152 throw new NotImplementedException ();
155 protected override void OnValidate (object value)
158 throw new ArgumentNullException ();
159 if (!(value is XmlElement
|| value is ServiceDescriptionFormatExtension
))
160 throw new ArgumentException ();
163 public void Remove (object extension
)
165 List
.Remove (extension
);
168 protected override void SetParent (object value, object parent
)
170 ServiceDescriptionFormatExtension extension
= value as ServiceDescriptionFormatExtension
;
171 if (extension
== null)
173 extension
.SetParent (parent
);
176 #endregion // Methods