2 // System.Web.Services.Description.PortTypeCollection.cs
\r
5 // Tim Coleman (tim@timcoleman.com)
\r
7 // Copyright (C) Tim Coleman, 2002
\r
10 namespace System.Web.Services.Description {
\r
11 public sealed class PortTypeCollection : ServiceDescriptionBaseCollection {
\r
15 ServiceDescription serviceDescription;
\r
17 #endregion // Fields
\r
19 #region Constructors
\r
21 internal PortTypeCollection (ServiceDescription serviceDescription)
\r
23 this.serviceDescription = serviceDescription;
\r
26 #endregion // Constructors
\r
30 public PortType this [int index] {
\r
32 if (index < 0 || index > Count)
\r
33 throw new ArgumentOutOfRangeException ();
\r
35 return (PortType) List[index];
\r
38 set { throw new NotImplementedException (); }
\r
41 public PortType this [string name] {
\r
42 get { return this[IndexOf ((PortType) Table[name])]; }
\r
45 #endregion // Properties
\r
49 public int Add (PortType portType)
\r
51 Insert (Count, portType);
\r
55 public bool Contains (PortType portType)
\r
57 return List.Contains (portType);
\r
60 public void CopyTo (PortType[] array, int index)
\r
62 List.CopyTo (array, index);
\r
65 protected override string GetKey (object value)
\r
67 if (!(value is PortType))
\r
68 throw new InvalidCastException ();
\r
69 return ((PortType) value).Name;
\r
72 public int IndexOf (PortType portType)
\r
74 return List.IndexOf (portType);
\r
77 public void Insert (int index, PortType portType)
\r
79 SetParent (portType, serviceDescription);
\r
80 Table [GetKey (portType)] = portType;
\r
81 List.Insert (index, portType);
\r
84 public void Remove (PortType portType)
\r
86 Table.Remove (GetKey (portType));
\r
87 List.Remove (portType);
\r
90 protected override void SetParent (object value, object parent)
\r
92 ((PortType) value).SetParent ((ServiceDescription) parent);
\r
95 #endregion // Methods
\r