~ubuntu-branches/ubuntu/quantal/smuxi/quantal

« back to all changes in this revision

Viewing changes to lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayIterator.cs

  • Committer: Package Import Robot
  • Author(s): Mirco Bauer
  • Date: 2012-01-07 12:13:22 UTC
  • mfrom: (1.1.9) (22.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20120107121322-x3tav345lpck4ty2
Tags: 0.8.9.1-3
* [7cd3a08] Ignore secur32(.dll) ModuleRef for dh_clideps
* [0055fc3] Added missing ncurses dllmap for smuxi-frontend-stfl.exe

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2004 - 2009  Versant Inc.  http://www.db4o.com */
 
2
 
 
3
using System;
 
4
using System.Collections;
 
5
using Db4objects.Db4o.Internal.Handlers.Array;
 
6
using Db4objects.Db4o.Reflect;
 
7
 
 
8
namespace Db4objects.Db4o.Internal.Handlers.Array
 
9
{
 
10
        /// <exclude></exclude>
 
11
        public class MultidimensionalArrayIterator : IEnumerator
 
12
        {
 
13
                private readonly IReflectArray _reflectArray;
 
14
 
 
15
                private readonly object[] _array;
 
16
 
 
17
                private int _currentElement;
 
18
 
 
19
                private IEnumerator _delegate;
 
20
 
 
21
                public MultidimensionalArrayIterator(IReflectArray reflectArray, object[] array)
 
22
                {
 
23
                        _reflectArray = reflectArray;
 
24
                        _array = array;
 
25
                        Reset();
 
26
                }
 
27
 
 
28
                public virtual object Current
 
29
                {
 
30
                        get
 
31
                        {
 
32
                                if (_delegate == null)
 
33
                                {
 
34
                                        return _array[_currentElement];
 
35
                                }
 
36
                                return _delegate.Current;
 
37
                        }
 
38
                }
 
39
 
 
40
                public virtual bool MoveNext()
 
41
                {
 
42
                        if (_delegate != null)
 
43
                        {
 
44
                                if (_delegate.MoveNext())
 
45
                                {
 
46
                                        return true;
 
47
                                }
 
48
                                _delegate = null;
 
49
                        }
 
50
                        _currentElement++;
 
51
                        if (_currentElement >= _array.Length)
 
52
                        {
 
53
                                return false;
 
54
                        }
 
55
                        object obj = _array[_currentElement];
 
56
                        Type clazz = obj.GetType();
 
57
                        if (clazz.IsArray)
 
58
                        {
 
59
                                if (clazz.GetElementType().IsArray)
 
60
                                {
 
61
                                        _delegate = new Db4objects.Db4o.Internal.Handlers.Array.MultidimensionalArrayIterator
 
62
                                                (_reflectArray, (object[])obj);
 
63
                                }
 
64
                                else
 
65
                                {
 
66
                                        _delegate = new ReflectArrayIterator(_reflectArray, obj);
 
67
                                }
 
68
                                return MoveNext();
 
69
                        }
 
70
                        return true;
 
71
                }
 
72
 
 
73
                public virtual void Reset()
 
74
                {
 
75
                        _currentElement = -1;
 
76
                        _delegate = null;
 
77
                }
 
78
        }
 
79
}