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