2002-07-25 Tim Coleman <tim@timcoleman.com>
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Description / PortTypeCollection.cs
1 // \r
2 // System.Web.Services.Description.PortTypeCollection.cs\r
3 //\r
4 // Author:\r
5 //   Tim Coleman (tim@timcoleman.com)\r
6 //\r
7 // Copyright (C) Tim Coleman, 2002\r
8 //\r
9 \r
10 namespace System.Web.Services.Description {\r
11         public sealed class PortTypeCollection : ServiceDescriptionBaseCollection {\r
12 \r
13                 #region Fields\r
14 \r
15                 ServiceDescription serviceDescription;\r
16 \r
17                 #endregion // Fields\r
18 \r
19                 #region Constructors\r
20 \r
21                 internal PortTypeCollection (ServiceDescription serviceDescription)\r
22                 {\r
23                         this.serviceDescription = serviceDescription;\r
24                 }\r
25 \r
26                 #endregion // Constructors\r
27 \r
28                 #region Properties\r
29 \r
30                 public PortType this [int index] {\r
31                         get { \r
32                                 if (index < 0 || index > Count)\r
33                                         throw new ArgumentOutOfRangeException ();\r
34 \r
35                                 return (PortType) List[index]; \r
36                         }\r
37                         [MonoTODO]\r
38                         set { throw new NotImplementedException (); }\r
39                 }\r
40 \r
41                 public PortType this [string name] {\r
42                         get { return this[IndexOf ((PortType) Table[name])]; }\r
43                 }\r
44 \r
45                 #endregion // Properties\r
46 \r
47                 #region Methods\r
48 \r
49                 public int Add (PortType portType) \r
50                 {\r
51                         Insert (Count, portType);       \r
52                         return (Count - 1);\r
53                 }\r
54 \r
55                 public bool Contains (PortType portType)\r
56                 {\r
57                         return List.Contains (portType);\r
58                 }\r
59 \r
60                 public void CopyTo (PortType[] array, int index) \r
61                 {\r
62                         List.CopyTo (array, index);\r
63                 }\r
64 \r
65                 protected override string GetKey (object value) \r
66                 {\r
67                         if (!(value is PortType))\r
68                                 throw new InvalidCastException ();\r
69                         return ((PortType) value).Name;\r
70                 }\r
71 \r
72                 public int IndexOf (PortType portType)\r
73                 {\r
74                         return List.IndexOf (portType);\r
75                 }\r
76 \r
77                 public void Insert (int index, PortType portType)\r
78                 {\r
79                         SetParent (portType, serviceDescription);\r
80                         Table [GetKey (portType)] = portType;\r
81                         List.Insert (index, portType);\r
82                 }\r
83         \r
84                 public void Remove (PortType portType)\r
85                 {\r
86                         Table.Remove (GetKey (portType));\r
87                         List.Remove (portType);\r
88                 }\r
89                         \r
90                 protected override void SetParent (object value, object parent)\r
91                 {\r
92                         ((PortType) value).SetParent ((ServiceDescription) parent); \r
93                 }\r
94                         \r
95                 #endregion // Methods\r
96         }\r
97 }\r