In corlib/System.Runtime.InteropServices:
[mono.git] / mcs / class / FirebirdSql.Data.Firebird / FirebirdSql.Data.Common / StringCollection.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 #if     (NETCF)
20
21 using System;
22 using System.Collections;
23
24 namespace System.Collections.Specialized
25 {
26         public class StringCollection : CollectionBase
27         {
28                 #region Indexers
29
30                 public string this[int index]
31                 {
32                         get { return ((string)base.List[index]); }
33                         set { base.List[index] = value; }
34                 }
35
36                 #endregion
37
38                 #region Methods
39
40                 public int Add(string value)
41                 {
42                         return (base.List.Add(value));
43                 }
44
45                 public void CopyTo(string[] array, int index)
46                 {
47                         if (array == null)
48                         {
49                                 throw new ArgumentNullException("array is null.");
50                         }
51                         if (index < 0)
52                         {
53                                 throw new ArgumentOutOfRangeException("index is less than zero.");
54                         }
55                         if (array.Rank > 1)
56                         {
57                                 throw new ArgumentException("array is multidimensional.");
58                         }
59                         if (index >= array.Length)
60                         {
61                                 throw new ArgumentException("index is equal to or greater than the length of array.");
62                         }
63                         if ((array.Length - index) < this.List.Count)
64                         {
65                                 throw new ArgumentException("The number of elements in the source StringCollection is greater than the available space from index to the end of the destination array.");
66                         }
67
68                         foreach (string value in this.List)
69                         {
70                                 if (index < array.Length)
71                                 {
72                                         array[index++] = value;
73                                 }
74                         }
75                 }
76
77                 public int IndexOf(string value)
78                 {
79                         return (base.List.IndexOf(value));
80                 }
81
82                 public void Insert(int index, string value)
83                 {
84                         base.List.Insert(index, value);
85                 }
86
87                 public void Remove(string value)
88                 {
89                         base.List.Remove(value);
90                 }
91
92                 public bool Contains(string value)
93                 {
94                         // If value     is not of type String, this     will return     false.
95                         return (base.List.Contains(value));
96                 }
97
98                 #endregion
99
100                 #region Protected MEthods
101
102                 protected override void OnValidate(Object value)
103                 {
104                         if (value.GetType() != Type.GetType("System.String"))
105                         {
106                                 throw new ArgumentException("value must be of type String.", "value");
107                         }
108                 }
109
110                 #endregion
111         }
112 }
113
114 #endif