ReferenceList.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 ([email protected])
  7. //
  8. // Copyright (C) Tim Coleman, 2004
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System.Collections;
  31. using System.Xml;
  32. namespace System.Security.Cryptography.Xml {
  33. public sealed class ReferenceList : IList, ICollection, IEnumerable {
  34. #region Fields
  35. ArrayList list;
  36. #endregion // Fields
  37. #region Constructors
  38. public ReferenceList ()
  39. {
  40. list = new ArrayList ();
  41. }
  42. #endregion // Constructors
  43. #region Properties
  44. public int Count {
  45. get { return list.Count; }
  46. }
  47. object IList.this [int index] {
  48. get { return this [index]; }
  49. set { this [index] = (EncryptedReference) value; }
  50. }
  51. public bool IsFixedSize {
  52. get { return list.IsFixedSize; }
  53. }
  54. public bool IsReadOnly {
  55. get { return list.IsReadOnly; }
  56. }
  57. public bool IsSynchronized {
  58. get { return list.IsSynchronized; }
  59. }
  60. public EncryptedReference this [int oid] {
  61. get { return (EncryptedReference) list [oid]; }
  62. set { this [oid] = value; }
  63. }
  64. public object SyncRoot {
  65. get { return list.SyncRoot; }
  66. }
  67. #endregion // Properties
  68. #region Methods
  69. public int Add (object value)
  70. {
  71. if (!(value is EncryptedReference))
  72. throw new ArgumentException ("value");
  73. return list.Add (value);
  74. }
  75. public void Clear ()
  76. {
  77. list.Clear ();
  78. }
  79. public bool Contains (object value)
  80. {
  81. return list.Contains (value);
  82. }
  83. public void CopyTo (Array array, int index)
  84. {
  85. list.CopyTo (array, index);
  86. }
  87. public IEnumerator GetEnumerator ()
  88. {
  89. return list.GetEnumerator ();
  90. }
  91. public int IndexOf (object value)
  92. {
  93. return list.IndexOf (value);
  94. }
  95. public void Insert (int index, object value)
  96. {
  97. if (!(value is EncryptedReference))
  98. throw new ArgumentException ("value");
  99. list.Insert (index, value);
  100. }
  101. public void Remove (object value)
  102. {
  103. list.Remove (value);
  104. }
  105. public void RemoveAt (int index)
  106. {
  107. list.RemoveAt (index);
  108. }
  109. #endregion // Methods
  110. }
  111. }
  112. #endif