Implement MachineKey.Protect and MachineKey.Unprotect
[mono.git] / mcs / class / System / System.Text.RegularExpressions / CaptureCollection.cs
1 //
2 // System.Text.RegularExpressions.CaptureCollection
3 //
4 // Authors:
5 //      Dan Lewis (dlewis@gmx.co.uk)
6 //      Dick Porter (dick@ximian.com)
7 //
8 // (C) 2002 Dan Lewis
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System.Collections;
32
33 namespace System.Text.RegularExpressions 
34 {
35         [Serializable]
36         public class CaptureCollection: ICollection, IEnumerable
37         {
38                 private Capture [] list;
39
40                 /* No public constructor */
41                 internal CaptureCollection (int n)
42                 {
43                         list = new Capture [n];
44                 }
45
46                 public int Count {
47                         get { return list.Length; }
48                 }
49
50                 public bool IsReadOnly {
51                         get { return true; }
52                 }
53
54                 public bool IsSynchronized {
55                         get { return false; }
56                 }
57
58                 public Capture this [int i] {
59                         get {
60                                 if (i < 0 || i >= Count)
61                                         throw new ArgumentOutOfRangeException ("Index is out of range");
62                                 return list [i];
63                         }
64                 }
65
66                 internal void SetValue (Capture cap, int i)
67                 {
68                         list [i] = cap;
69                 }
70
71                 public object SyncRoot {
72                         get { return list; }
73                 }
74
75                 public void CopyTo (Array array, int arrayIndex)
76                 {
77                         list.CopyTo (array, arrayIndex);
78                 }
79
80                 public IEnumerator GetEnumerator ()
81                 {
82                         return list.GetEnumerator ();
83                 }
84         }
85 }