2010-04-06 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.Design / System.Windows.Forms.Design.Behavior / BehaviorServiceAdornerCollectionEnumerator.cs
blob4709f0f5231ecc24b79f700ffd67e9134499f369
1 //
2 // System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator
3 //
4 // Author:
5 // Atsushi Enomoto (atsushi@ximian.com)
6 //
7 // Copyright (C) 2007 Novell, Inc.
8 //
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.
31 #if NET_2_0
33 using System.Collections;
35 namespace System.Windows.Forms.Design.Behavior
37 public class BehaviorServiceAdornerCollectionEnumerator : IEnumerator
39 BehaviorServiceAdornerCollection mappings;
40 int index, state;
42 public BehaviorServiceAdornerCollectionEnumerator (BehaviorServiceAdornerCollection mappings)
44 if (mappings == null)
45 throw new ArgumentNullException ("mappings");
46 this.mappings = mappings;
48 Reset ();
51 public Adorner Current {
52 get { return index < 0 ? null : mappings [index]; }
55 void CheckState ()
57 if (mappings.State != state)
58 throw new InvalidOperationException ("Collection has changed");
61 public bool MoveNext ()
63 CheckState ();
64 if (index++ < mappings.Count)
65 return true;
66 index--;
67 return false;
70 public void Reset ()
72 index = -1;
75 object IEnumerator.Current {
76 get { return Current; }
79 bool IEnumerator.MoveNext ()
81 return MoveNext ();
84 void IEnumerator.Reset ()
86 Reset ();
91 #endif