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