2003-10-04 Sebastien Pouliot <spouliot@videotron.ca>
[mono.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services / SoapInputFilterCollection.cs
1 //
2 // SoapInputFilterCollection.cs: Soap Input Filter Collection
3 //
4 // Author:
5 //      Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
9
10 using System;
11 using System.Collections;
12
13 namespace Microsoft.Web.Services {
14
15         public class SoapInputFilterCollection : CollectionBase, ICloneable {
16
17                 public SoapInputFilterCollection () {}
18
19                 internal SoapInputFilterCollection (ArrayList list) 
20                 {
21                         InnerList.AddRange (list);
22                 }
23
24                 public SoapInputFilter this [int index] {
25                         get { return (SoapInputFilter) InnerList [index]; }
26                 }
27
28                 public int Add (SoapInputFilter filter) 
29                 {
30                         if (filter == null)
31                                 throw new ArgumentNullException ("filter");
32                         return InnerList.Add (filter);
33                 }
34
35                 public void AddRange (ICollection filters) 
36                 {
37                         // can't use list.AddRange because we must check every items
38                         // in the collection
39                         foreach (object o in filters) {
40                                 if (! (o is SoapInputFilter))
41                                         throw new ArgumentException ("not SoapInputFilter");
42                                 // we'll get the ArgumentNullException in Add
43                                 InnerList.Add (o as SoapInputFilter);
44                         }
45                 }
46
47                 // LAMESPEC: Shallow (implemented) or deep clone (todo)
48                 public object Clone () 
49                 {
50                         return new SoapInputFilterCollection ((ArrayList) InnerList.Clone ());
51                 }
52
53                 public bool Contains (SoapInputFilter filter) 
54                 {
55                         if (filter == null)
56                                 throw new ArgumentNullException ("filter");
57                         return InnerList.Contains (filter);
58                 }
59
60                 public bool Contains (Type filterType) 
61                 {
62                         foreach (object o in InnerList) {
63                                 if (o.GetType () == filterType)
64                                         return true;
65                         }
66                         return false;
67                 }
68
69                 public int IndexOf (SoapInputFilter filter) 
70                 {
71                         if (filter == null)
72                                 throw new ArgumentNullException ("filter");
73                         return InnerList.IndexOf (filter);
74                 }
75
76                 public int IndexOf (Type filterType) 
77                 {
78                         if (filterType == null)
79                                 throw new ArgumentNullException ("filterType");
80                         int i = 0;
81                         foreach (object o in InnerList) {
82                                 if (o.GetType () == filterType)
83                                         return i;
84                                 i++;
85                         }
86                         return -1;
87                 }
88
89                 public void Insert (int index, SoapInputFilter filter) 
90                 {
91                         if (filter == null)
92                                 throw new ArgumentNullException ("filter");
93                         InnerList.Insert (index, filter);
94                 }
95
96                 public void Remove (SoapInputFilter filter) 
97                 {
98                         if (filter == null)
99                                 throw new ArgumentNullException ("filter");
100                         InnerList.Remove (filter);
101                 }
102
103                 public void Remove (Type filterType) 
104                 {
105                         if (filterType == null)
106                                 throw new ArgumentNullException ("filterType");
107                         int i = 0;
108                         foreach (object o in InnerList) {
109                                 if (o.GetType () == filterType)
110                                         InnerList.RemoveAt (i);
111                                 i++;
112                         }
113                 }
114         }
115 }