ReferenceList.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. // 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. using System.Collections;
  31. using System.Runtime.CompilerServices;
  32. using System.Xml;
  33. namespace System.Security.Cryptography.Xml {
  34. public sealed class ReferenceList : IList, ICollection, IEnumerable {
  35. #region Fields
  36. ArrayList list;
  37. #endregion // Fields
  38. #region Constructors
  39. public ReferenceList ()
  40. {
  41. list = new ArrayList ();
  42. }
  43. #endregion // Constructors
  44. #region Properties
  45. public int Count {
  46. get { return list.Count; }
  47. }
  48. object IList.this [int index] {
  49. get { return this [index]; }
  50. set { this [index] = (EncryptedReference) value; }
  51. }
  52. bool IList.IsFixedSize {
  53. get { return false; }
  54. }
  55. bool IList.IsReadOnly {
  56. get { return false; }
  57. }
  58. public bool IsSynchronized {
  59. get { return list.IsSynchronized; }
  60. }
  61. [IndexerName ("ItemOf")]
  62. public EncryptedReference this [int index] {
  63. get { return (EncryptedReference) list [index]; }
  64. set { list [index] = value; }
  65. }
  66. public object SyncRoot {
  67. get { return list.SyncRoot; }
  68. }
  69. #endregion // Properties
  70. #region Methods
  71. public int Add (object value)
  72. {
  73. if (!(value is EncryptedReference))
  74. throw new ArgumentException ("value");
  75. return list.Add (value);
  76. }
  77. public void Clear ()
  78. {
  79. list.Clear ();
  80. }
  81. public bool Contains (object value)
  82. {
  83. return list.Contains (value);
  84. }
  85. public void CopyTo (Array array, int index)
  86. {
  87. list.CopyTo (array, index);
  88. }
  89. public IEnumerator GetEnumerator ()
  90. {
  91. return list.GetEnumerator ();
  92. }
  93. public EncryptedReference Item (int index)
  94. {
  95. return (EncryptedReference) list [index];
  96. }
  97. public int IndexOf (object value)
  98. {
  99. return list.IndexOf (value);
  100. }
  101. public void Insert (int index, object value)
  102. {
  103. if (!(value is EncryptedReference))
  104. throw new ArgumentException ("value");
  105. list.Insert (index, value);
  106. }
  107. public void Remove (object value)
  108. {
  109. list.Remove (value);
  110. }
  111. public void RemoveAt (int index)
  112. {
  113. list.RemoveAt (index);
  114. }
  115. #endregion // Methods
  116. }
  117. }