/* * LargeArray.Enumerator.cs * * Copyright © 2009 * Diversified Technical Systems, Inc. * All Rights Reserved */ using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; using System.Text; using DTS.Common.Utilities; using DTS.Common.Utilities.DotNetProgrammingConstructs; namespace DTS.Common.Utilities.IO.MemoryMap { // *** see LargeArray.cs *** public partial class LargeArray { /// /// An enumerator class for . /// public class Enumerator : Exceptional, IEnumerator { /// /// Initialize an instance of the class. /// /// /// /// The object to be operated upon by this instance. /// /// public Enumerator(LargeArray enumeratee) { try { Enumeratee = enumeratee; CurrentIndex = (Enumeratee.LargeCount > 0 ? (ulong?)0 : null); } catch (System.Exception ex) { throw new Exception("encountered problem ", ex); } } /// /// Get the that his enumerator object is /// acting upon. /// protected LargeArray Enumeratee { get => _Enumeratee.Value; private set => _Enumeratee.Value = value; } private Property> _Enumeratee = new Property>( typeof(Enumerator).FullName + ".Enumeratee", null, false ); /// /// The index of the current item. /// private ulong? CurrentIndex { get; set; } #region IEnumerator interface // ********************************************************************* // ******************** BEGIN IEnumerator Interface ******************** // ********************************************************************* /// /// Get the current element in the collection. /// /// /// /// The enumerator is positioned before the first element of the collection or after the last element OR... /// The collection was modified after the enumerator was created. /// /// public object Current { get { try { if (null == CurrentIndex) throw new InvalidOperationException("the current position is outside of the collection"); else if ( /*EnumerateeHasBeenModified*/ true) throw new InvalidOperationException("the collection has been modified since this enumerator was created"); //else return Enumeratee[ (ulong) CurrentIndex ]; - inaccessible code - 6/9/2010 - dtm } catch (InvalidOperationException) { throw; } catch (System.Exception ex) { throw new Exception("encountered problem getting current element in the collection", ex); } } } /// /// Advances the enumerator to the next element of the collection. /// /// /// /// true if the enumerator was successfully advanced to the next /// element; false if the enumerator has passed the end of the collection. /// /// /// /// The collection was modified after the enumerator was created. /// /// public bool MoveNext() { //try //{ throw new NotSupportedException("MemoryMapArray MoveNext not supported"); //} //catch (InvalidOperationException ex) { throw ex; } //catch (System.Exception ex) //{ // throw new Exception("encountered problem advancing to the next element of the collection", ex); //} } /// /// Sets the enumerator to its initial position, which is before the first element /// in the collection. /// /// /// /// The collection was modified after the enumerator was created. /// /// public void Reset() { //try //{ // // TODO: implement throw new NotSupportedException("MemoryMap.LargeArray Reset not supported"); //} //catch (InvalidOperationException) { throw; } //catch (System.Exception ex) //{ // throw new Exception("encountered problem setting the enumerator to its initial position", ex); //} } // ******************************************************************* // ******************** END IEnumerator Interface ******************** // ******************************************************************* #endregion } } }