New test.
[mono.git] / mcs / class / System.Security / System.Security.Cryptography.Xml / ReferenceList.cs
1 //
2 // ReferenceList.cs - ReferenceList implementation for XML Encryption
3 // http://www.w3.org/2001/04/xmlenc#sec-ReferenceList
4 //
5 // Author:
6 //      Tim Coleman (tim@timcoleman.com)
7 //
8 // Copyright (C) Tim Coleman, 2004
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32
33 using System.Collections;
34 using System.Runtime.CompilerServices;
35 using System.Xml;
36
37 namespace System.Security.Cryptography.Xml {
38
39         public sealed class ReferenceList : IList, ICollection, IEnumerable {
40
41                 #region Fields
42
43                 ArrayList list;
44
45                 #endregion // Fields
46
47                 #region Constructors
48
49                 public ReferenceList ()
50                 {
51                         list = new ArrayList ();
52                 }
53         
54                 #endregion // Constructors
55
56                 #region Properties
57
58                 public int Count {
59                         get { return list.Count; }
60                 }
61
62                 object IList.this [int index] {
63                         get { return this [index]; }
64                         set { this [index] = (EncryptedReference) value; }
65                 }
66
67                 bool IList.IsFixedSize {
68                         get { return false; }
69                 }
70
71                 bool IList.IsReadOnly {
72                         get { return false; }
73                 }
74
75                 public bool IsSynchronized {
76                         get { return list.IsSynchronized; }
77                 }
78
79                 [IndexerName ("ItemOf")]
80                 public EncryptedReference this [int index] {
81                         get { return (EncryptedReference) list [index]; }
82                         set { this [index] = value; }
83                 }
84
85                 public object SyncRoot {
86                         get { return list.SyncRoot; }
87                 }
88
89                 #endregion // Properties
90
91                 #region Methods
92
93                 public int Add (object value)
94                 {
95                         if (!(value is EncryptedReference))
96                                 throw new ArgumentException ("value");
97                         return list.Add (value);
98                 }
99
100                 public void Clear ()
101                 {
102                         list.Clear ();
103                 }
104
105                 public bool Contains (object value)
106                 {
107                         return list.Contains (value);
108                 }
109
110                 public void CopyTo (Array array, int index)
111                 {
112                         list.CopyTo (array, index);
113                 }
114
115                 public IEnumerator GetEnumerator ()
116                 {
117                         return list.GetEnumerator ();
118                 }
119
120                 public EncryptedReference Item (int index)
121                 {
122                         return (EncryptedReference) list [index];
123                 }
124
125                 public int IndexOf (object value)
126                 {
127                         return list.IndexOf (value);
128                 }
129
130                 public void Insert (int index, object value)
131                 {
132                         if (!(value is EncryptedReference))
133                                 throw new ArgumentException ("value");
134                         list.Insert (index, value);
135                 }
136
137                 public void Remove (object value)
138                 {
139                         list.Remove (value);
140                 }
141
142                 public void RemoveAt (int index)
143                 {
144                         list.RemoveAt (index);
145                 }
146
147                 #endregion // Methods
148         }
149 }
150
151 #endif