2 // System.Web.Services.Description.ServiceDescriptionCollection.cs
5 // Tim Coleman (tim@timcoleman.com)
6 // Lluis Sanchez Gual (lluis@ximian.com)
8 // Copyright (C) Tim Coleman, 2002
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:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
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.
32 using System.Web.Services;
35 namespace System.Web.Services.Description {
36 public sealed class ServiceDescriptionCollection : ServiceDescriptionBaseCollection {
38 #if !TARGET_JVM //code generation is not supported
39 ServiceDescriptionImporter importer;
44 public ServiceDescriptionCollection ()
49 #endregion // Constructors
53 public ServiceDescription this [int index] {
55 if (index < 0 || index > Count)
56 throw new ArgumentOutOfRangeException ();
58 return (ServiceDescription) List[index];
60 set { List [index] = value; }
63 public ServiceDescription this [string ns] {
65 return (ServiceDescription) Table[ns];
69 #endregion // Properties
72 #if !TARGET_JVM //code generation is not supported
73 internal void SetImporter (ServiceDescriptionImporter i)
78 public int Add (ServiceDescription serviceDescription)
80 Insert (Count, serviceDescription);
84 public bool Contains (ServiceDescription serviceDescription)
86 return List.Contains (serviceDescription);
89 public void CopyTo (ServiceDescription[] array, int index)
91 List.CopyTo (array, index);
94 public Binding GetBinding (XmlQualifiedName name)
96 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
98 foreach (Binding binding in desc.Bindings)
99 if (binding.Name == name.Name)
102 throw new InvalidOperationException ("Binding '" + name + "' not found");
105 protected override string GetKey (object value)
107 return ((ServiceDescription) value).TargetNamespace;
110 public Message GetMessage (XmlQualifiedName name)
112 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
114 foreach (Message message in desc.Messages)
115 if (message.Name == name.Name)
118 throw new InvalidOperationException ("Message '" + name + "' not found");
121 public PortType GetPortType (XmlQualifiedName name)
123 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
125 foreach (PortType portType in desc.PortTypes)
126 if (portType.Name == name.Name)
129 throw new InvalidOperationException ("Port type '" + name + "' not found");
132 public Service GetService (XmlQualifiedName name)
134 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
136 foreach (Service service in desc.Services)
137 if (service.Name == name.Name)
140 throw new InvalidOperationException ("Service '" + name + "' not found");
143 public int IndexOf (ServiceDescription serviceDescription)
145 return List.IndexOf (serviceDescription);
148 public void Insert (int index, ServiceDescription serviceDescription)
150 List.Insert (index, serviceDescription);
151 OnInsertComplete (index, serviceDescription);
154 public void Remove (ServiceDescription serviceDescription)
156 List.Remove (serviceDescription);
163 void OnInsertComplete (int index, object item)
165 base.OnInsertComplete (index, item);
170 protected override void SetParent (object value, object parent)
175 #endregion // Methods