2 // System.Web.Services.Description.ServiceDescriptionCollection.cs
\r
5 // Tim Coleman (tim@timcoleman.com)
\r
6 // Lluis Sanchez Gual (lluis@ximian.com)
\r
8 // Copyright (C) Tim Coleman, 2002
\r
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;
\r
35 namespace System.Web.Services.Description {
\r
36 public sealed class ServiceDescriptionCollection : ServiceDescriptionBaseCollection {
\r
38 #region Constructors
\r
40 public ServiceDescriptionCollection ()
\r
45 #endregion // Constructors
\r
49 public ServiceDescription this [int index] {
\r
51 if (index < 0 || index > Count)
\r
52 throw new ArgumentOutOfRangeException ();
\r
54 return (ServiceDescription) List[index];
\r
56 set { List [index] = value; }
\r
59 public ServiceDescription this [string ns] {
\r
61 return (ServiceDescription) Table[ns];
\r
65 #endregion // Properties
\r
69 public int Add (ServiceDescription serviceDescription)
\r
71 Insert (Count, serviceDescription);
\r
75 public bool Contains (ServiceDescription serviceDescription)
\r
77 return List.Contains (serviceDescription);
\r
80 public void CopyTo (ServiceDescription[] array, int index)
\r
82 List.CopyTo (array, index);
\r
85 public Binding GetBinding (XmlQualifiedName name)
\r
87 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
\r
89 foreach (Binding binding in desc.Bindings)
\r
90 if (binding.Name == name.Name)
\r
93 throw new InvalidOperationException ("Binding '" + name + "' not found");
\r
96 protected override string GetKey (object value)
\r
98 return ((ServiceDescription) value).TargetNamespace;
\r
101 public Message GetMessage (XmlQualifiedName name)
\r
103 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
\r
104 if (desc != null) {
\r
105 foreach (Message message in desc.Messages)
\r
106 if (message.Name == name.Name)
\r
109 throw new InvalidOperationException ("Message '" + name + "' not found");
\r
112 public PortType GetPortType (XmlQualifiedName name)
\r
114 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
\r
115 if (desc != null) {
\r
116 foreach (PortType portType in desc.PortTypes)
\r
117 if (portType.Name == name.Name)
\r
120 throw new InvalidOperationException ("Port type '" + name + "' not found");
\r
123 public Service GetService (XmlQualifiedName name)
\r
125 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
\r
126 if (desc != null) {
\r
127 foreach (Service service in desc.Services)
\r
128 if (service.Name == name.Name)
\r
131 throw new InvalidOperationException ("Service '" + name + "' not found");
\r
134 public int IndexOf (ServiceDescription serviceDescription)
\r
136 return List.IndexOf (serviceDescription);
\r
139 public void Insert (int index, ServiceDescription serviceDescription)
\r
141 List.Insert (index, serviceDescription);
\r
144 public void Remove (ServiceDescription serviceDescription)
\r
146 List.Remove (serviceDescription);
\r
149 #endregion // Methods
\r