OleDbErrorCollection.cs 3.4 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. public sealed class OleDbErrorCollection : ICollection, IEnumerable
  41. {
  42. #region Fields
  43. ArrayList list;
  44. #endregion // Fields
  45. #region Constructors
  46. internal OleDbErrorCollection() {
  47. }
  48. #endregion Constructors
  49. #region Properties
  50. public int Count {
  51. get {
  52. return list.Count;
  53. }
  54. }
  55. public OleDbError this[int index] {
  56. get {
  57. return (OleDbError) list[index];
  58. }
  59. }
  60. object ICollection.SyncRoot {
  61. get {
  62. return list.SyncRoot;
  63. }
  64. }
  65. bool ICollection.IsSynchronized {
  66. get {
  67. return list.IsSynchronized;
  68. }
  69. }
  70. #endregion // Properties
  71. #region Methods
  72. internal void Add (OleDbError error)
  73. {
  74. list.Add ((object) error);
  75. }
  76. public void CopyTo (Array array, int index)
  77. {
  78. if (array == null)
  79. throw new ArgumentNullException("array");
  80. if ((index < array.GetLowerBound (0)) || (index > array.GetUpperBound (0)))
  81. throw new ArgumentOutOfRangeException("index");
  82. // is the check for IsFixedSize required?
  83. if ((array.IsFixedSize) || (index + this.Count > array.GetUpperBound (0)))
  84. throw new ArgumentException("array");
  85. ((OleDbError[])(list.ToArray ())).CopyTo (array, index);
  86. }
  87. public IEnumerator GetEnumerator ()
  88. {
  89. return list.GetEnumerator ();
  90. }
  91. IEnumerator IEnumerable.GetEnumerator ()
  92. {
  93. return GetEnumerator ();
  94. }
  95. #endregion // Methods
  96. }
  97. }