// ------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph { using System.Collections.Generic; /// /// A page of results from a collection. /// /// The type of the item contained within the collection. public class CollectionPage : ICollectionPage { /// /// Creates the collection page. /// public CollectionPage() { this.CurrentPage = new List(); } /// /// Creates the collection page. /// /// The current page. public CollectionPage(IList currentPage) { this.CurrentPage = currentPage; } /// /// The current page. /// public IList CurrentPage { get; private set; } /// /// Get the index of an item in the current page. /// /// The item to get the index for. /// public int IndexOf(T item) { return this.CurrentPage.IndexOf(item); } /// /// Insert an item into the current page. /// /// The index to insert the item at. /// The item to insert. public void Insert(int index, T item) { this.CurrentPage.Insert(index, item); } /// /// Remove the item at the given index. /// /// The index to remove an item at. public void RemoveAt(int index) { this.CurrentPage.RemoveAt(index); } /// /// Access the item at the given index. /// /// The item's index. /// The item of type T. public T this[int index] { get { return this.CurrentPage[index]; } set { this.CurrentPage[index] = value; } } /// /// Add an item to the current page. /// /// The item to add. public void Add(T item) { this.CurrentPage.Add(item); } /// /// Remove all items from the current page. /// public void Clear() { this.CurrentPage.Clear(); } /// /// Determine whether the current page contains the given item. /// /// The item to search for. /// True if the item is found. public bool Contains(T item) { return this.CurrentPage.Contains(item); } /// /// Copies the elements of the current page to the given array starting at the given index. /// /// The array to copy elements to. /// The start index. public void CopyTo(T[] array, int arrayIndex) { this.CurrentPage.CopyTo(array, arrayIndex); } /// /// Gets the number of elements in the current page. /// public int Count { get { return this.CurrentPage.Count; } } /// /// Determines whether the current page is readonly. /// public bool IsReadOnly { get { return this.CurrentPage.IsReadOnly; } } /// /// Removes an item from the current page. /// /// The item to remove. /// public bool Remove(T item) { return this.CurrentPage.Remove(item); } /// /// Returns an enumerator that iterates through the current page. /// /// The enumerator for the current page. public IEnumerator GetEnumerator() { return this.CurrentPage.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return this.CurrentPage.GetEnumerator(); } /// /// The additional data property bag. /// public IDictionary AdditionalData { get; set; } } }