2 using System.Collections.Generic;
5 using System.Threading.Tasks;
9 public class WrappedListException : Exception
11 public WrappedListException()
15 public WrappedListException(string message)
20 public WrappedListException(string message, Exception inner)
21 : base(message, inner)
26 public class WrappedList<T>
29 private List<T> Elements;
31 public WrappedList(IList<T> List, int Start)
33 Elements = new List<T>(List);
37 public WrappedList(IList<T> List)
39 Elements = new List<T>(List);
45 if (Elements.Count <= Index)
47 throw new WrappedListException("No elements left.");
50 return Elements[Index++];
53 public T[] GetItems(int Count)
55 if (Elements.Count - Index < Count)
57 throw new WrappedListException("Unable to read requested amount of data.");
60 T[] result = Elements.Skip<T>(Index).Take<T>(Count).ToArray<T>();
66 public IEnumerable<T> GetEnumerableItems(int Count)
68 if (Elements.Count - Index < Count)
70 throw new WrappedListException("Unable to read requested amount of data.");
73 IEnumerable<T> result = Elements.Skip<T>(Index).Take<T>(Count);