OleDbErrorCollection.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // System.Data.OleDb.OleDbErrorCollection
  3. //
  4. // Authors:
  5. // Rodrigo Moya ([email protected])
  6. // Tim Coleman ([email protected])
  7. //
  8. // Copyright (C) Rodrigo Moya, 2002
  9. // Copyright (C) Tim Coleman, 2002
  10. //
  11. //
  12. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  13. //
  14. // Permission is hereby granted, free of charge, to any person obtaining
  15. // a copy of this software and associated documentation files (the
  16. // "Software"), to deal in the Software without restriction, including
  17. // without limitation the rights to use, copy, modify, merge, publish,
  18. // distribute, sublicense, and/or sell copies of the Software, and to
  19. // permit persons to whom the Software is furnished to do so, subject to
  20. // the following conditions:
  21. //
  22. // The above copyright notice and this permission notice shall be
  23. // included in all copies or substantial portions of the Software.
  24. //
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  29. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  30. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  31. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32. //
  33. using System.Collections;
  34. using System.ComponentModel;
  35. using System.Data;
  36. using System.Data.Common;
  37. namespace System.Data.OleDb
  38. {
  39. [ListBindableAttribute ( false)]
  40. [Serializable]
  41. public sealed class OleDbErrorCollection : ICollection, IEnumerable
  42. {
  43. #region Fields
  44. ArrayList items;
  45. #endregion // Fields
  46. #region Constructors
  47. internal OleDbErrorCollection() {
  48. }
  49. #endregion Constructors
  50. #region Properties
  51. public int Count {
  52. get {
  53. return items.Count;
  54. }
  55. }
  56. public OleDbError this[int index] {
  57. get {
  58. return (OleDbError) items[index];
  59. }
  60. }
  61. object ICollection.SyncRoot {
  62. get {
  63. return items.SyncRoot;
  64. }
  65. }
  66. bool ICollection.IsSynchronized {
  67. get {
  68. return items.IsSynchronized;
  69. }
  70. }
  71. #endregion // Properties
  72. #region Methods
  73. internal void Add (OleDbError error)
  74. {
  75. items.Add ((object) error);
  76. }
  77. public void CopyTo (Array array, int index)
  78. {
  79. if (array == null)
  80. throw new ArgumentNullException("array");
  81. if ((index < array.GetLowerBound (0)) || (index > array.GetUpperBound (0)))
  82. throw new ArgumentOutOfRangeException("index");
  83. // is the check for IsFixedSize required?
  84. if ((array.IsFixedSize) || (index + this.Count > array.GetUpperBound (0)))
  85. throw new ArgumentException("array");
  86. ((OleDbError[]) (items.ToArray ())).CopyTo (array, index);
  87. }
  88. public IEnumerator GetEnumerator ()
  89. {
  90. return items.GetEnumerator ();
  91. }
  92. IEnumerator IEnumerable.GetEnumerator ()
  93. {
  94. return GetEnumerator ();
  95. }
  96. #endregion // Methods
  97. }
  98. }