OdbcErrorCollection.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // System.Data.Odbc.OdbcErrorCollection
  3. //
  4. // Author:
  5. // Brian Ritchie ([email protected])
  6. //
  7. // Copyright (C) Brian Ritchie, 2002
  8. //
  9. using System.Collections;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Data.Common;
  13. namespace System.Data.Odbc
  14. {
  15. public sealed class OdbcErrorCollection : ICollection, IEnumerable
  16. {
  17. #region Fields
  18. ArrayList list = new ArrayList ();
  19. #endregion // Fields
  20. #region Constructors
  21. internal OdbcErrorCollection() {
  22. }
  23. #endregion Constructors
  24. #region Properties
  25. public int Count
  26. {
  27. get
  28. {
  29. return list.Count;
  30. }
  31. }
  32. public OdbcError this[int index]
  33. {
  34. get
  35. {
  36. return (OdbcError) list[index];
  37. }
  38. }
  39. object ICollection.SyncRoot
  40. {
  41. get
  42. {
  43. return list.SyncRoot;
  44. }
  45. }
  46. bool ICollection.IsSynchronized
  47. {
  48. get
  49. {
  50. return list.IsSynchronized;
  51. }
  52. }
  53. #endregion // Properties
  54. #region Methods
  55. internal void Add (OdbcError error)
  56. {
  57. list.Add ((object) error);
  58. }
  59. public void CopyTo (Array array, int index)
  60. {
  61. if (array == null)
  62. throw new ArgumentNullException("array");
  63. if ((index < array.GetLowerBound (0)) || (index > array.GetUpperBound (0)))
  64. throw new ArgumentOutOfRangeException("index");
  65. // is the check for IsFixedSize required?
  66. if ((array.IsFixedSize) || (index + this.Count > array.GetUpperBound (0)))
  67. throw new ArgumentException("array");
  68. ((OdbcError[])(list.ToArray ())).CopyTo (array, index);
  69. }
  70. public IEnumerator GetEnumerator ()
  71. {
  72. return list.GetEnumerator ();
  73. }
  74. IEnumerator IEnumerable.GetEnumerator ()
  75. {
  76. return GetEnumerator ();
  77. }
  78. #endregion // Methods
  79. }
  80. }