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.Xml; 8 9 namespace System.Security.Cryptography.Xml 10 { 11 public sealed class EncryptionPropertyCollection : IList 12 { 13 private ArrayList _props; 14 EncryptionPropertyCollection()15 public EncryptionPropertyCollection() 16 { 17 _props = new ArrayList(); 18 } 19 GetEnumerator()20 public IEnumerator GetEnumerator() 21 { 22 return _props.GetEnumerator(); 23 } 24 25 public int Count 26 { 27 get { return _props.Count; } 28 } 29 30 /// <internalonly/> IList.Add(object value)31 int IList.Add(object value) 32 { 33 if (!(value is EncryptionProperty)) 34 throw new ArgumentException(SR.Cryptography_Xml_IncorrectObjectType, nameof(value)); 35 36 return _props.Add(value); 37 } 38 Add(EncryptionProperty value)39 public int Add(EncryptionProperty value) 40 { 41 return _props.Add(value); 42 } 43 Clear()44 public void Clear() 45 { 46 _props.Clear(); 47 } 48 49 /// <internalonly/> IList.Contains(object value)50 bool IList.Contains(object value) 51 { 52 if (!(value is EncryptionProperty)) 53 throw new ArgumentException(SR.Cryptography_Xml_IncorrectObjectType, nameof(value)); 54 55 return _props.Contains(value); 56 } 57 Contains(EncryptionProperty value)58 public bool Contains(EncryptionProperty value) 59 { 60 return _props.Contains(value); 61 } 62 63 /// <internalonly/> IList.IndexOf(object value)64 int IList.IndexOf(object value) 65 { 66 if (!(value is EncryptionProperty)) 67 throw new ArgumentException(SR.Cryptography_Xml_IncorrectObjectType, nameof(value)); 68 69 return _props.IndexOf(value); 70 } 71 IndexOf(EncryptionProperty value)72 public int IndexOf(EncryptionProperty value) 73 { 74 return _props.IndexOf(value); 75 } 76 77 /// <internalonly/> IList.Insert(int index, object value)78 void IList.Insert(int index, object value) 79 { 80 if (!(value is EncryptionProperty)) 81 throw new ArgumentException(SR.Cryptography_Xml_IncorrectObjectType, nameof(value)); 82 83 _props.Insert(index, value); 84 } 85 Insert(int index, EncryptionProperty value)86 public void Insert(int index, EncryptionProperty value) 87 { 88 _props.Insert(index, value); 89 } 90 91 /// <internalonly/> IList.Remove(object value)92 void IList.Remove(object value) 93 { 94 if (!(value is EncryptionProperty)) 95 throw new ArgumentException(SR.Cryptography_Xml_IncorrectObjectType, nameof(value)); 96 97 _props.Remove(value); 98 } 99 Remove(EncryptionProperty value)100 public void Remove(EncryptionProperty value) 101 { 102 _props.Remove(value); 103 } 104 RemoveAt(int index)105 public void RemoveAt(int index) 106 { 107 _props.RemoveAt(index); 108 } 109 110 public bool IsFixedSize 111 { 112 get { return _props.IsFixedSize; } 113 } 114 115 public bool IsReadOnly 116 { 117 get { return _props.IsReadOnly; } 118 } 119 Item(int index)120 public EncryptionProperty Item(int index) 121 { 122 return (EncryptionProperty)_props[index]; 123 } 124 125 [System.Runtime.CompilerServices.IndexerName("ItemOf")] 126 public EncryptionProperty this[int index] 127 { 128 get 129 { 130 return (EncryptionProperty)((IList)this)[index]; 131 } 132 set 133 { 134 ((IList)this)[index] = value; 135 } 136 } 137 138 /// <internalonly/> 139 object IList.this[int index] 140 { 141 get { return _props[index]; } 142 set 143 { 144 if (!(value is EncryptionProperty)) 145 throw new ArgumentException(SR.Cryptography_Xml_IncorrectObjectType, nameof(value)); 146 147 _props[index] = value; 148 } 149 } 150 CopyTo(Array array, int index)151 public void CopyTo(Array array, int index) 152 { 153 _props.CopyTo(array, index); 154 } 155 CopyTo(EncryptionProperty[] array, int index)156 public void CopyTo(EncryptionProperty[] array, int index) 157 { 158 _props.CopyTo(array, index); 159 } 160 161 public object SyncRoot 162 { 163 get { return _props.SyncRoot; } 164 } 165 166 public bool IsSynchronized 167 { 168 get { return _props.IsSynchronized; } 169 } 170 } 171 } 172