public ListCursor(ListCursor <T> Cursor) { this.List = Cursor.List; this.Position = Cursor.Position; this.Index = Cursor.Index; this.StayAtFlag = Cursor.StayAtFlag; }
public ListCursor <T> Next( ) { int nxIndex = -1; // stay at the current location. if (StayAtFlag == true) { if (this.Position != RelativePosition.At) { throw new ApplicationException("cursor not position at location to stay at"); } StayAtFlag = false; nxIndex = this.Index; } else { switch (this.Position) { case RelativePosition.Begin: nxIndex = 0; break; case RelativePosition.Before: nxIndex = this.Index; break; case RelativePosition.At: nxIndex = this.Index + 1; break; case RelativePosition.After: nxIndex = this.Index + 1; break; case RelativePosition.End: nxIndex = -1; break; default: throw new ApplicationException("Next failed. Relative position is not set"); } } if ((nxIndex == -1) || (nxIndex >= this.List.Count)) { return(null); } else { var csr = new ListCursor <T>(this.List, nxIndex, RelativePosition.At); return(csr); } }
public ListCursor <T> PositionBefore() { if (_Position == RelativePosition.Begin) { return(PositionBegin()); } else if (_Position == RelativePosition.End) { return(PositionEnd()); } else if (_Position == RelativePosition.None) { throw new ApplicationException("PositionBefore cursor is set to None"); } else { var csr = new ListCursor <T>(this.List, this.Index, RelativePosition.Before); return(csr); } }