cosmetic diff
[mono.git] / mcs / class / FirebirdSql.Data.Firebird / FirebirdSql.Data.Firebird / FbErrorCollection.cs
1 /*
2  *      Firebird ADO.NET Data provider for .NET and Mono 
3  * 
4  *         The contents of this file are subject to the Initial 
5  *         Developer's Public License Version 1.0 (the "License"); 
6  *         you may not use this file except in compliance with the 
7  *         License. You may obtain a copy of the License at 
8  *         http://www.firebirdsql.org/index.php?op=doc&id=idpl
9  *
10  *         Software distributed under the License is distributed on 
11  *         an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
12  *         express or implied. See the License for the specific 
13  *         language governing rights and limitations under the License.
14  * 
15  *      Copyright (c) 2002, 2005 Carlos Guzman Alvarez
16  *      All Rights Reserved.
17  */
18
19 using System;
20 using System.Collections;
21 using System.ComponentModel;
22
23 using FirebirdSql.Data.Common;
24
25 namespace FirebirdSql.Data.Firebird
26 {
27         /// <include file='Doc/en_EN/FbErrorCollection.xml'     path='doc/class[@name="FbErrorCollection"]/overview/*'/>
28 #if     (!NETCF)
29         [Serializable, ListBindable(false)]
30 #endif
31         public sealed class FbErrorCollection : ICollection, IEnumerable
32         {
33                 #region Fields
34
35                 private ArrayList errors;
36
37                 #endregion
38
39                 #region Indexers
40
41                 /// <include file='Doc/en_EN/FbErrorCollection.xml'     path='doc/class[@name="FbErrorCollection"]/indexer[@name="Item(System.Int32)"]/*'/>
42                 public FbError this[int index]
43                 {
44                         get { return (FbError)this.errors[index]; }
45                 }
46
47                 #endregion
48
49                 #region Constructors
50
51                 internal FbErrorCollection()
52                 {
53                         this.errors = ArrayList.Synchronized(new ArrayList());
54                 }
55
56                 #endregion
57
58                 #region ICollection     Properties
59
60                 /// <include file='Doc/en_EN/FbErrorCollection.xml'     path='doc/class[@name="FbErrorCollection"]/property[@name="Count"]/*'/>
61                 public int Count
62                 {
63                         get { return this.errors.Count; }
64                 }
65
66                 bool ICollection.IsSynchronized
67                 {
68                         get { return this.errors.IsSynchronized; }
69                 }
70
71                 object ICollection.SyncRoot
72                 {
73                         get { return this.errors.SyncRoot; }
74                 }
75
76                 #endregion
77
78                 #region ICollection     Methods
79
80                 /// <include file='Doc/en_EN/FbErrorCollection.xml'     path='doc/class[@name="FbErrorCollection"]/method[@name="CopyTo(System.Array,System.Int32)"]/*'/>       
81                 public void CopyTo(Array array, int index)
82                 {
83                         this.errors.CopyTo(array, index);
84                 }
85
86                 #endregion
87
88                 #region IEnumerable     Methods
89
90                 IEnumerator IEnumerable.GetEnumerator()
91                 {
92                         return this.errors.GetEnumerator();
93                 }
94
95                 #endregion
96
97                 #region Internal Methods
98
99                 /// <include file='Doc/en_EN/FbErrorCollection.xml'     path='doc/class[@name="FbErrorCollection"]/method[@name="IndexOf(System.String)"]/*'/>          
100                 internal int IndexOf(string errorMessage)
101                 {
102                         int index = 0;
103                         foreach (FbError item in this)
104                         {
105                                 if (GlobalizationHelper.CultureAwareCompare(item.Message, errorMessage))
106                                 {
107                                         return index;
108                                 }
109                                 index++;
110                         }
111
112                         return -1;
113                 }
114
115                 /// <include file='Doc/en_EN/FbErrorCollection.xml'     path='doc/class[@name="FbErrorCollection"]/method[@name="Add(FbError)"]/*'/>
116                 internal FbError Add(FbError error)
117                 {
118                         this.errors.Add(error);
119
120                         return error;
121                 }
122
123                 /// <include file='Doc/en_EN/FbErrorCollection.xml'     path='doc/class[@name="FbErrorCollection"]/method[@name="Add(System.String,System.Int32)"]/*'/>
124                 internal FbError Add(string errorMessage, int number)
125                 {
126                         FbError error = new FbError(errorMessage, number);
127
128                         return this.Add(error);
129                 }
130
131                 #endregion
132         }
133 }