copied mono-api-diff.cs from mono-2-2 branch so new patch can be applied and history...
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Description / ServiceDescriptionCollection.cs
1 // 
2 // System.Web.Services.Description.ServiceDescriptionCollection.cs
3 //
4 // Author:
5 //   Tim Coleman (tim@timcoleman.com)
6 //   Lluis Sanchez Gual (lluis@ximian.com)
7 //
8 // Copyright (C) Tim Coleman, 2002
9 //
10
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 using System.Web.Services;
33 using System.Xml;
34
35 namespace System.Web.Services.Description {
36         public sealed class ServiceDescriptionCollection : ServiceDescriptionBaseCollection {
37
38 #if !TARGET_JVM //code generation is not supported
39                 ServiceDescriptionImporter importer;
40 #endif
41                 
42                 #region Constructors
43         
44                 public ServiceDescriptionCollection () 
45                         : base (null)
46                 {
47                 }
48
49                 #endregion // Constructors
50
51                 #region Properties
52
53                 public ServiceDescription this [int index] {
54                         get { 
55                                 if (index < 0 || index > Count)
56                                         throw new ArgumentOutOfRangeException ();
57
58                                 return (ServiceDescription) List[index]; 
59                         }
60                         set { List [index] = value; }
61                 }
62
63                 public ServiceDescription this [string ns] {
64                         get { 
65                                 return (ServiceDescription) Table[ns];
66                         }
67                 }
68
69                 #endregion // Properties
70
71                 #region Methods
72 #if !TARGET_JVM //code generation is not supported
73                 internal void SetImporter (ServiceDescriptionImporter i)
74                 {
75                         importer = i;
76                 }
77 #endif
78                 public int Add (ServiceDescription serviceDescription) 
79                 {
80                         Insert (Count, serviceDescription);
81                         return (Count - 1);
82                 }
83                 
84                 public bool Contains (ServiceDescription serviceDescription)
85                 {
86                         return List.Contains (serviceDescription);
87                 }
88
89                 public void CopyTo (ServiceDescription[] array, int index) 
90                 {
91                         List.CopyTo (array, index);
92                 }
93
94                 public Binding GetBinding (XmlQualifiedName name)
95                 {
96                         foreach (ServiceDescription desc in List) {
97                                 if (desc.TargetNamespace == name.Namespace) {
98                                         foreach (Binding binding in desc.Bindings) 
99                                                 if (binding.Name == name.Name)
100                                                         return binding;
101                                 }
102                         }
103                         throw new InvalidOperationException ("Binding '" + name + "' not found");
104                 }
105
106                 protected override string GetKey (object value) 
107                 {
108                         return ((ServiceDescription) value).TargetNamespace;
109                 }
110
111                 public Message GetMessage (XmlQualifiedName name)
112                 {
113                         foreach (ServiceDescription desc in List) {
114                                 if (desc.TargetNamespace == name.Namespace) {
115                                         foreach (Message message in desc.Messages) 
116                                                 if (message.Name == name.Name)
117                                                         return message;
118                                 }
119                         }
120                         throw new InvalidOperationException ("Message '" + name + "' not found");
121                 }
122
123                 public PortType GetPortType (XmlQualifiedName name)
124                 {
125                         foreach (ServiceDescription desc in List) {
126                                 if (desc.TargetNamespace == name.Namespace) {
127                                         foreach (PortType portType in desc.PortTypes) 
128                                                 if (portType.Name == name.Name)
129                                                         return portType;
130                                 }
131                         }
132                         throw new InvalidOperationException ("Port type '" + name + "' not found");
133                 }
134
135                 public Service GetService (XmlQualifiedName name)
136                 {
137                         foreach (ServiceDescription desc in List) {
138                                 if (desc.TargetNamespace == name.Namespace) {
139                                         foreach (Service service in desc.Services) 
140                                                 if (service.Name == name.Name)
141                                                         return service;
142                                 }
143                         }
144                         throw new InvalidOperationException ("Service '" + name + "' not found");
145                 }
146
147                 public int IndexOf (ServiceDescription serviceDescription)
148                 {
149                         return List.IndexOf (serviceDescription);
150                 }
151
152                 public void Insert (int index, ServiceDescription serviceDescription)
153                 {
154                         List.Insert (index, serviceDescription);
155                         OnInsertComplete (index, serviceDescription);
156                 }
157         
158                 public void Remove (ServiceDescription serviceDescription)
159                 {
160                         List.Remove (serviceDescription);
161                 }
162
163 #if NET_2_0
164                 [MonoTODO]
165                 protected override
166 #endif
167                 void OnInsertComplete (int index, object item)
168                 {
169                         base.OnInsertComplete (index, item);
170                 }
171
172 #if NET_2_0
173                 [MonoTODO]
174                 protected override void SetParent (object value, object parent)
175                 {
176                 }
177 #endif
178
179                 #endregion // Methods
180         }
181 }