* SqlException.cs: Modified HResult/ErrorCode to match MS. Removed
[mono.git] / mcs / class / System.Data / System.Data.SqlClient / SqlErrorCollection.cs
1 //
2 // System.Data.SqlClient.SqlErrorCollection.cs
3 //
4 // Author:
5 //   Rodrigo Moya (rodrigo@ximian.com)
6 //   Daniel Morgan (danmorg@sc.rr.com)
7 //   Tim Coleman (tim@timcoleman.com)
8 //
9 // (C) Ximian, Inc 2002
10 // Copyright (C) Tim Coleman, 2002
11 //
12
13 //
14 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
15 //
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
23 // 
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
26 // 
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 //
35 using System;
36 using System.Collections;
37 using System.ComponentModel;
38 using System.Data;
39 using System.Runtime.InteropServices;
40
41 namespace System.Data.SqlClient {
42         [ListBindable (false)]
43         [Serializable]
44         public sealed class SqlErrorCollection : ICollection, IEnumerable
45         {
46                 #region Fields
47
48                 ArrayList list = new ArrayList();
49
50                 #endregion // Fields
51
52                 #region Constructors
53
54                 internal SqlErrorCollection () 
55                 {
56                 }
57
58                 internal SqlErrorCollection (byte theClass, int lineNumber, string message, int number, string procedure, string server, string source, byte state) 
59                 {
60                         Add (theClass, lineNumber, message, number, procedure, server, source, state);
61                 }
62
63                 #endregion // Constructors
64
65                 #region Properties
66                 
67                 public int Count {
68                         get { return list.Count; }                        
69                 }
70
71                 bool ICollection.IsSynchronized {
72                         get { return list.IsSynchronized; }
73                 }
74
75                 object ICollection.SyncRoot {
76                         get { return list.SyncRoot; }
77                 }
78
79                 public SqlError this[int index] {
80                         get { return (SqlError) list [index]; }
81                 }
82
83                 #endregion
84
85                 #region Methods
86                 
87                 internal void Add(SqlError error) 
88                 {
89                         list.Add (error);
90                 }
91
92                 internal void Add(byte theClass, int lineNumber, string message, int number, string procedure, string server, string source, byte state) 
93                 {
94                         SqlError error = new SqlError (theClass, lineNumber, message, number, procedure, server, source, state);
95                         Add (error);
96                 }
97
98                 public void CopyTo (Array array, int index) 
99                 {
100                         list.CopyTo (array, index);
101                 }
102
103                 public IEnumerator GetEnumerator() 
104                 {
105                         return list.GetEnumerator ();
106                 }
107
108 #if NET_2_0
109                 public void CopyTo (SqlError[] array, int index)
110                 {
111                         list.CopyTo (array, index);
112                 }
113
114 #endif // NET_2_0
115
116                 #endregion              
117         }
118 }