2
0

OdbcErrorCollection.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 Properties
  21. public int Count
  22. {
  23. get
  24. {
  25. return list.Count;
  26. }
  27. }
  28. public OdbcError this[int index]
  29. {
  30. get
  31. {
  32. return (OdbcError) list[index];
  33. }
  34. }
  35. object ICollection.SyncRoot
  36. {
  37. get
  38. {
  39. return list.SyncRoot;
  40. }
  41. }
  42. bool ICollection.IsSynchronized
  43. {
  44. get
  45. {
  46. return list.IsSynchronized;
  47. }
  48. }
  49. #endregion // Properties
  50. #region Methods
  51. public void Add (OdbcError error)
  52. {
  53. list.Add ((object) error);
  54. }
  55. public void CopyTo (Array array, int index)
  56. {
  57. if (array == null)
  58. throw new ArgumentNullException("array");
  59. if ((index < array.GetLowerBound (0)) || (index > array.GetUpperBound (0)))
  60. throw new ArgumentOutOfRangeException("index");
  61. // is the check for IsFixedSize required?
  62. if ((array.IsFixedSize) || (index + this.Count > array.GetUpperBound (0)))
  63. throw new ArgumentException("array");
  64. ((OdbcError[])(list.ToArray ())).CopyTo (array, index);
  65. }
  66. public IEnumerator GetEnumerator ()
  67. {
  68. return list.GetEnumerator ();
  69. }
  70. IEnumerator IEnumerable.GetEnumerator ()
  71. {
  72. return GetEnumerator ();
  73. }
  74. #endregion // Methods
  75. }
  76. }