1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System;
6 using System.Collections;
7 using System.Collections.Generic;
8 using System.Text;
9 using System.Threading.Tasks;
10 
11 namespace System.Security.Cryptography.Xml
12 {
13     public sealed class ReferenceList : IList
14     {
15         private ArrayList _references;
16 
ReferenceList()17         public ReferenceList()
18         {
19             _references = new ArrayList();
20         }
21 
GetEnumerator()22         public IEnumerator GetEnumerator()
23         {
24             return _references.GetEnumerator();
25         }
26 
27         public int Count
28         {
29             get { return _references.Count; }
30         }
31 
Add(object value)32         public int Add(object value)
33         {
34             if (value == null)
35                 throw new ArgumentNullException(nameof(value));
36 
37             if (!(value is DataReference) && !(value is KeyReference))
38                 throw new ArgumentException(SR.Cryptography_Xml_IncorrectObjectType, nameof(value));
39 
40             return _references.Add(value);
41         }
42 
Clear()43         public void Clear()
44         {
45             _references.Clear();
46         }
47 
Contains(object value)48         public bool Contains(object value)
49         {
50             return _references.Contains(value);
51         }
52 
IndexOf(object value)53         public int IndexOf(object value)
54         {
55             return _references.IndexOf(value);
56         }
57 
Insert(int index, object value)58         public void Insert(int index, object value)
59         {
60             if (value == null)
61                 throw new ArgumentNullException(nameof(value));
62 
63             if (!(value is DataReference) && !(value is KeyReference))
64                 throw new ArgumentException(SR.Cryptography_Xml_IncorrectObjectType, nameof(value));
65 
66             _references.Insert(index, value);
67         }
68 
Remove(object value)69         public void Remove(object value)
70         {
71             _references.Remove(value);
72         }
73 
RemoveAt(int index)74         public void RemoveAt(int index)
75         {
76             _references.RemoveAt(index);
77         }
78 
Item(int index)79         public EncryptedReference Item(int index)
80         {
81             return (EncryptedReference)_references[index];
82         }
83 
84         [System.Runtime.CompilerServices.IndexerName("ItemOf")]
85         public EncryptedReference this[int index]
86         {
87             get
88             {
89                 return Item(index);
90             }
91             set
92             {
93                 ((IList)this)[index] = value;
94             }
95         }
96 
97         /// <internalonly/>
98         object IList.this[int index]
99         {
100             get { return _references[index]; }
101             set
102             {
103                 if (value == null)
104                     throw new ArgumentNullException(nameof(value));
105 
106                 if (!(value is DataReference) && !(value is KeyReference))
107                     throw new ArgumentException(SR.Cryptography_Xml_IncorrectObjectType, nameof(value));
108 
109                 _references[index] = value;
110             }
111         }
112 
CopyTo(Array array, int index)113         public void CopyTo(Array array, int index)
114         {
115             _references.CopyTo(array, index);
116         }
117 
118         bool IList.IsFixedSize
119         {
120             get { return _references.IsFixedSize; }
121         }
122 
123         bool IList.IsReadOnly
124         {
125             get { return _references.IsReadOnly; }
126         }
127 
128         public object SyncRoot
129         {
130             get { return _references.SyncRoot; }
131         }
132 
133         public bool IsSynchronized
134         {
135             get { return _references.IsSynchronized; }
136         }
137     }
138 }
139