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 ServiceDescriptionImporter importer;
40 #region Constructors
\r
42 public ServiceDescriptionCollection ()
\r
47 #endregion // Constructors
\r
51 public ServiceDescription this [int index] {
\r
53 if (index < 0 || index > Count)
\r
54 throw new ArgumentOutOfRangeException ();
\r
56 return (ServiceDescription) List[index];
\r
58 set { List [index] = value; }
\r
61 public ServiceDescription this [string ns] {
\r
63 return (ServiceDescription) Table[ns];
\r
67 #endregion // Properties
\r
71 internal void SetImporter (ServiceDescriptionImporter i)
76 public int Add (ServiceDescription serviceDescription)
\r
78 if (importer != null)
\r
79 importer.OnServiceDescriptionAdded (serviceDescription, null, null);
80 Insert (Count, serviceDescription);
84 internal int Add (ServiceDescription serviceDescription, string appSettingUrlKey, string appSettingBaseUrl)
\r
86 if (importer != null)
\r
87 importer.OnServiceDescriptionAdded (serviceDescription, appSettingUrlKey, appSettingBaseUrl);
88 Insert (Count, serviceDescription);
92 public bool Contains (ServiceDescription serviceDescription)
\r
94 return List.Contains (serviceDescription);
\r
97 public void CopyTo (ServiceDescription[] array, int index)
\r
99 List.CopyTo (array, index);
\r
102 public Binding GetBinding (XmlQualifiedName name)
\r
104 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
\r
105 if (desc != null) {
\r
106 foreach (Binding binding in desc.Bindings)
\r
107 if (binding.Name == name.Name)
\r
110 throw new InvalidOperationException ("Binding '" + name + "' not found");
\r
113 protected override string GetKey (object value)
\r
115 return ((ServiceDescription) value).TargetNamespace;
\r
118 public Message GetMessage (XmlQualifiedName name)
\r
120 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
\r
121 if (desc != null) {
\r
122 foreach (Message message in desc.Messages)
\r
123 if (message.Name == name.Name)
\r
126 throw new InvalidOperationException ("Message '" + name + "' not found");
\r
129 public PortType GetPortType (XmlQualifiedName name)
\r
131 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
\r
132 if (desc != null) {
\r
133 foreach (PortType portType in desc.PortTypes)
\r
134 if (portType.Name == name.Name)
\r
137 throw new InvalidOperationException ("Port type '" + name + "' not found");
\r
140 public Service GetService (XmlQualifiedName name)
\r
142 ServiceDescription desc = (ServiceDescription) Table[name.Namespace];
\r
143 if (desc != null) {
\r
144 foreach (Service service in desc.Services)
\r
145 if (service.Name == name.Name)
\r
148 throw new InvalidOperationException ("Service '" + name + "' not found");
\r
151 public int IndexOf (ServiceDescription serviceDescription)
\r
153 return List.IndexOf (serviceDescription);
\r
156 public void Insert (int index, ServiceDescription serviceDescription)
\r
158 List.Insert (index, serviceDescription);
\r
161 public void Remove (ServiceDescription serviceDescription)
\r
163 List.Remove (serviceDescription);
\r
166 #endregion // Methods
\r