/[RomCheater]/trunk/RomCheater/Serialization/SearchResultReader.cs
ViewVC logotype

Diff of /trunk/RomCheater/Serialization/SearchResultReader.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/Serialization/SearchResultReader.cs	2013/06/06 03:17:53	557
+++ trunk/RomCheater/Serialization/SearchResultReader.cs	2013/06/06 03:33:46	558
@@ -25,6 +25,7 @@
 using System.Windows.Forms;
 using RomCheater.Core;
 using System.Diagnostics;
+using System.Collections;
 
 namespace RomCheater.Serialization
 {
@@ -153,7 +154,7 @@
     
 
     #region public class SearchResultReader : SerializationReader, ISearchResultReader, ISerializedResult
-    public class SearchResultReader : SerializationReader, ISearchResultReader, ISerializedResult<ulong> , IEnumerable<StructResultType<ulong>>
+    public class SearchResultReader : SerializationReader, ISearchResultReader, ISerializedResult<ulong>, IEnumerator<StructResultType<ulong>>//, IEnumerable<StructResultType<ulong>>
     {
         //private Guid _ResultGuid;
         //private Guid ResultGuid { get { return _ResultGuid; } set { _ResultGuid = value; } }
@@ -168,16 +169,66 @@
         //[Obsolete("SearchResultReader(Guid guid, bool delete) should not be used")]
         //public SearchResultReader(Guid guid, bool delete) : base(guid, delete) { ResultGuid = guid; ReadHeader(); }
 
-        #region  IEnumerator<StructResultType<ulong>> members
-        public IEnumerator<StructResultType<ulong>> GetEnumerator()
+        #region IEnumerator support
+        private void CheckIndexLessThanMin()
         {
-            return (IEnumerator<StructResultType<ulong>>)results.GetEnumerator();
+            if (_index < MinimumIndex)
+            {
+                throw new ArgumentOutOfRangeException("index", string.Format("index cannot be less than {0}", MinimumIndex));
+            }
         }
-        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+        private void CheckIndexGreaterThanMax()
         {
-            return GetEnumerator();
+            if (_index > MaximumIndex)
+            {
+                throw new ArgumentOutOfRangeException("index", string.Format("index cannot be greater than {0}", MaximumIndex));
+            }
+        }
+        private int _index = -1;
+        private int index { get { return _index; } set { _index = value; } }
+        public StructResultType<ulong> Current
+        {
+            get
+            {
+                // result the current entry (at position)
+                //throw new NotImplementedException(); 
+                CheckIndexLessThanMin();
+                CheckIndexGreaterThanMax();
+                return results[index];
+            }
+        }
+        object IEnumerator.Current
+        {
+            get { return this.Current; }
+        }
+
+        public bool MoveNext()
+        {
+            this.index++; // increment after processing index at MinimumIndex               
+            if (this.index >= this.MinimumIndex && this.index <= this.MaximumIndex)
+            {
+                return true;
+            }
+            Reset();
+            return false;
+        }
+
+        public void Reset()
+        {
+            this.index = -1;
         }
         #endregion
+
+        //#region  IEnumerator<StructResultType<ulong>> members
+        //public IEnumerator<StructResultType<ulong>> GetEnumerator()
+        //{
+        //    return (IEnumerator<StructResultType<ulong>>)results.GetEnumerator();
+        //}
+        //System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+        //{
+        //    return GetEnumerator();
+        //}
+        //#endregion
         #region ISerializedResult<T> members
         //public ResultReaderCollection GetResultCollection()
         //{

 

  ViewVC Help
Powered by ViewVC 1.1.22