OleDbErrorCollection.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //------------------------------------------------------------------------------
  2. // <copyright file="OleDbErrorCollection.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // <owner current="true" primary="true">[....]</owner>
  6. // <owner current="true" primary="false">[....]</owner>
  7. //------------------------------------------------------------------------------
  8. namespace System.Data.OleDb {
  9. using System;
  10. using System.ComponentModel;
  11. using System.Collections;
  12. using System.Data.Common;
  13. [Serializable, ListBindable(false)]
  14. public sealed class OleDbErrorCollection : System.Collections.ICollection {
  15. readonly private ArrayList items; // WebData 106655
  16. internal OleDbErrorCollection(UnsafeNativeMethods.IErrorInfo errorInfo) {
  17. ArrayList items = new ArrayList();
  18. Bid.Trace("<oledb.IUnknown.QueryInterface|API|OS> IErrorRecords\n");
  19. UnsafeNativeMethods.IErrorRecords errorRecords = (errorInfo as UnsafeNativeMethods.IErrorRecords);
  20. if (null != errorRecords) {
  21. int recordCount = errorRecords.GetRecordCount();
  22. Bid.Trace("<oledb.IErrorRecords.GetRecordCount|API|OS|RET> RecordCount=%d\n", recordCount);
  23. for (int i = 0; i < recordCount; ++i) {
  24. OleDbError error = new OleDbError(errorRecords, i);
  25. items.Add(error);
  26. }
  27. }
  28. this.items = items;
  29. }
  30. bool System.Collections.ICollection.IsSynchronized {
  31. get { return false;}
  32. }
  33. object System.Collections.ICollection.SyncRoot {
  34. get { return this;}
  35. }
  36. public int Count {
  37. get {
  38. ArrayList items = this.items;
  39. return ((null != items) ? items.Count : 0);
  40. }
  41. }
  42. public OleDbError this[int index] {
  43. get {
  44. return (this.items[index] as OleDbError);
  45. }
  46. }
  47. internal void AddRange(ICollection c) {
  48. items.AddRange(c);
  49. }
  50. public void CopyTo(Array array, int index) {
  51. this.items.CopyTo(array, index);
  52. }
  53. public void CopyTo (OleDbError[] array, int index) {
  54. this.items.CopyTo(array, index);
  55. }
  56. public IEnumerator GetEnumerator() {
  57. return this.items.GetEnumerator();
  58. }
  59. }
  60. }