OleDbErrorCollection.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. using System.Collections;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Data.Common;
  15. namespace System.Data.OleDb
  16. {
  17. [ListBindableAttribute ( false)]
  18. public sealed class OleDbErrorCollection : ICollection, IEnumerable
  19. {
  20. #region Fields
  21. ArrayList list;
  22. #endregion // Fields
  23. #region Constructors
  24. internal OleDbErrorCollection() {
  25. }
  26. #endregion Constructors
  27. #region Properties
  28. public int Count {
  29. get {
  30. return list.Count;
  31. }
  32. }
  33. public OleDbError this[int index] {
  34. get {
  35. return (OleDbError) list[index];
  36. }
  37. }
  38. object ICollection.SyncRoot {
  39. get {
  40. return list.SyncRoot;
  41. }
  42. }
  43. bool ICollection.IsSynchronized {
  44. get {
  45. return list.IsSynchronized;
  46. }
  47. }
  48. #endregion // Properties
  49. #region Methods
  50. internal void Add (OleDbError error)
  51. {
  52. list.Add ((object) error);
  53. }
  54. public void CopyTo (Array array, int index)
  55. {
  56. if (array == null)
  57. throw new ArgumentNullException("array");
  58. if ((index < array.GetLowerBound (0)) || (index > array.GetUpperBound (0)))
  59. throw new ArgumentOutOfRangeException("index");
  60. // is the check for IsFixedSize required?
  61. if ((array.IsFixedSize) || (index + this.Count > array.GetUpperBound (0)))
  62. throw new ArgumentException("array");
  63. ((OleDbError[])(list.ToArray ())).CopyTo (array, index);
  64. }
  65. public IEnumerator GetEnumerator ()
  66. {
  67. return list.GetEnumerator ();
  68. }
  69. IEnumerator IEnumerable.GetEnumerator ()
  70. {
  71. return GetEnumerator ();
  72. }
  73. #endregion // Methods
  74. }
  75. }