Mark tests as not working under TARGET_JVM
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Description / ServiceDescriptionFormatExtensionCollection.cs
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 //
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:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
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.
29 //
30
31 using System.Collections;
32 using System.Web.Services;
33 using System.Xml;
34
35 namespace System.Web.Services.Description {
36         public sealed class ServiceDescriptionFormatExtensionCollection : ServiceDescriptionBaseCollection {
37                 
38                 #region Constructors
39         
40                 public ServiceDescriptionFormatExtensionCollection (object parent) 
41                         : base (parent)
42                 {
43                 }
44
45                 #endregion // Constructors
46
47                 #region Properties
48
49                 public object this [int index] {
50                         get { 
51                                 if (index < 0 || index > Count)
52                                         throw new ArgumentOutOfRangeException ();
53
54                                 return List[index]; 
55                         }
56                         set { List[index] = value; }
57                 }
58
59                 #endregion // Properties
60
61                 #region Methods
62
63                 public int Add (object extension) 
64                 {
65                         Insert (Count, extension);
66                         return (Count - 1);
67                 }
68
69                 public bool Contains (object extension)
70                 {
71                         return List.Contains (extension);
72                 }
73
74                 public void CopyTo (object[] array, int index) 
75                 {
76                         List.CopyTo (array, index);
77                 }
78
79                 public object Find (Type type)
80                 {
81                         foreach (object value in List)
82                                 if (type.IsInstanceOfType (value))
83                                         return value;
84                         return null;
85                 }
86
87                 public XmlElement Find (string name, string ns)
88                 {
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)
94                                                 return xmlElement;
95                                 }
96                         return null;
97                 }
98
99                 public object[] FindAll (Type type)
100                 {
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];
106
107                         if (searchResults.Count > 0)
108                                 searchResults.CopyTo (returnValue);
109
110                         return returnValue;
111                 }
112
113                 public XmlElement[] FindAll (string name, string ns)
114                 {
115                         ArrayList searchResults = new ArrayList ();
116                         XmlElement xmlElement;
117
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);
123                                 }
124
125                         XmlElement[] returnValue = new XmlElement [searchResults.Count];
126
127                         if (searchResults.Count > 0)
128                                 searchResults.CopyTo (returnValue);
129
130                         return returnValue;
131                 }
132
133                 public int IndexOf (object extension)
134                 {
135                         return List.IndexOf (extension);
136                 }
137
138                 public void Insert (int index, object extension)
139                 {
140                         List.Insert (index, extension);
141                 }
142
143                 [MonoTODO]
144                 public bool IsHandled (object item)
145                 {
146                         throw new NotImplementedException ();
147                 }
148
149                 [MonoTODO]
150                 public bool IsRequired (object item)
151                 {
152                         throw new NotImplementedException ();
153                 }
154         
155                 protected override void OnValidate (object value)
156                 {
157                         if (value == null)
158                                 throw new ArgumentNullException ();
159                         if (!(value is XmlElement || value is ServiceDescriptionFormatExtension))
160                                 throw new ArgumentException ();
161                 }
162         
163                 public void Remove (object extension)
164                 {
165                         List.Remove (extension);
166                 }
167                         
168                 protected override void SetParent (object value, object parent)
169                 {
170                         ServiceDescriptionFormatExtension extension = value as ServiceDescriptionFormatExtension;
171                         if (extension == null)
172                                 return;
173                         extension.SetParent (parent);
174                 }
175                         
176                 #endregion // Methods
177         }
178 }