public Option <MediaItem> Peek(int offset) { if (offset == 0) { return(Current); } if ((State.Index + offset) % _mediaItemCount == 0) { IList <MediaItem> shuffled; Option <MediaItem> tail = Current; // clone the random CloneableRandom randomCopy = _random.Clone(); do { int newSeed = randomCopy.Next(); randomCopy = new CloneableRandom(newSeed); shuffled = Shuffle(_mediaItems, randomCopy); } while (_mediaItems.Count > 1 && shuffled[0] == tail); return(shuffled.Any() ? shuffled[0] : None); } return(_shuffled.Any() ? _shuffled[(State.Index + offset) % _mediaItemCount] : None); }
public ProgramScheduleItem Peek(int offset) { if (offset == 0) { return(Current); } if ((State.Index + offset) % _scheduleItemsCount == 0) { IList <ProgramScheduleItem> shuffled; ProgramScheduleItem tail = Current; // clone the random CloneableRandom randomCopy = _random.Clone(); do { int newSeed = randomCopy.Next(); randomCopy = new CloneableRandom(newSeed); shuffled = Shuffle(_scheduleItems, randomCopy); } while (_scheduleItems.Count > 1 && shuffled[0] == tail); return(shuffled[0]); } return(_shuffled[(State.Index + offset) % _scheduleItemsCount]); }