Class PageDataCollection
A collection of PageData objects.
Inheritance
Implements
Inherited Members
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 11.20.7Syntax
public class PageDataCollection : IList<PageData>, ICollection<PageData>, IEnumerable<PageData>, IList, ICollection, IEnumerable
Remarks
Control authors might need to fill this kind of collection from code. Mostly you'll work on collections retrieved by a GetChildren(...) call or from a Web control.
The GetChildren(...) method defined on the IPageSource interface returns a PageDataCollection. The IPageSource interface is implemented by many classes like PageBase (and descendants), DataFactory, PageControlBase (which most Web controls inherit from) and more.
PageDataCollection is often used together with other EPiServer classes, see the following HowTo articles which demonstrate some ways in which it can be used: Search for pages created recently and Search for pages based on page type property.
Examples
The following code example demonstrates the usage of <strong>PageDataCollection</strong>.
// must be called from inside a class that implements IPageSource,
// like SimplePage or TemplatePage.
PageDataCollection oPages;
oPages = this.GetChildren(EPiServer.Core.PageReference.StartPage);
Response.Write("Number of pages below startpage: " + oPages.Count);
Constructors
PageDataCollection()
Initializes a new instance of the PageDataCollection class that is empty and has the default initial capacity.
Declaration
public PageDataCollection()
PageDataCollection(IEnumerable<PageData>)
Initializes a new instance of the PageDataCollection class that contains elements copied from the specified collection and has sufficient capacity to accomodate the number of elements copied.
Declaration
public PageDataCollection(IEnumerable<PageData> collection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<PageData> | collection | The page collection whose elements are copied to the new list. |
PageDataCollection(IEnumerable<RawPage>)
Create and copy PageData elements array of RawPage objects.
Declaration
[Obsolete("No longer used, content is imported through IContentImporter and IPropertyImporter")]
public PageDataCollection(IEnumerable<RawPage> rawPages)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<RawPage> | rawPages | A collection of RawPage objects that are used to populate the PageDataCollection. |
PageDataCollection(IEnumerable)
Initializes a new instance of the PageDataCollection class that contains elements copied from the specified collection and has sufficient capacity to accomodate the number of elements copied.
Declaration
[Obsolete("No longer supported, use other constructor")]
public PageDataCollection(IEnumerable e)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | e |
Remarks
Supports any System.Collections.IEnumerable that contains PageData or RawPage
Note that in the case of an System.Collections.IEnumerable with PageData instances, this constructor will reference the same instance of the PageData objects as the original enumerable, but for RawPage instances it will create new PageData objects.
PageDataCollection(Int32)
Initializes a new instance of the PageDataCollection class that is empty and has the specified initial capacity.
Declaration
public PageDataCollection(int capacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | The number of elements that the collection can initally store. |
Properties
Count
Number of pages in collection
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Returns the number of pages in the collection. |
IsFixedSize
Gets a value indicating whether the PageDataCollection has a fixed size.
Declaration
public bool IsFixedSize { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Always false for PageDataCollection. |
IsReadOnly
Gets a value indicating whether the ICollection is read-only (defalut value is false).
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsSynchronized
Gets a value indicating whether access is synchronized (thread-safe).
Declaration
public bool IsSynchronized { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Item[Int32]
Access PageData objects using index
Declaration
public PageData this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
PageData |
SyncRoot
Gets an object that can be used to synchronize access to the internal collection.
Declaration
public object SyncRoot { get; }
Property Value
Type | Description |
---|---|
System.Object |
Methods
Add(PageData)
Add new page to collection
Declaration
public void Add(PageData page)
Parameters
Type | Name | Description |
---|---|---|
PageData | page | Page to add |
Add(PageDataCollection)
Add a range of pages from another PageDataCollection.
Declaration
public void Add(PageDataCollection pages)
Parameters
Type | Name | Description |
---|---|---|
PageDataCollection | pages | The collection whos elements should be added to the end of the current instance. |
Add(IEnumerable<PageData>)
Add a range of pages from another collection.
Declaration
public void Add(IEnumerable<PageData> pages)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<PageData> | pages | The collection whos elements should be added to the end of the current instance. |
Add(Object)
Adds an item, which must be of type PageData, to the PageDataCollection.
Declaration
public int Add(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The System.Object to add to the PageDataCollection. |
Returns
Type | Description |
---|---|
System.Int32 | The position into which the new element was inserted. |
Clear()
Remove all items in list
Declaration
public void Clear()
Contains(PageData)
Determines whether an PageData is in the Collection.
Declaration
public bool Contains(PageData item)
Parameters
Type | Name | Description |
---|---|---|
PageData | item | The PageData to locate in the List. The value can be a null reference. |
Returns
Type | Description |
---|---|
System.Boolean |
Contains(Object)
Determines whether the PageDataCollection contains a specific value.
Declaration
public bool Contains(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The System.Object to locate in the PageDataCollection. |
Returns
Type | Description |
---|---|
System.Boolean | true if the System.Object is found in the PageDataCollection; otherwise, false. |
Copy()
Make a deep copy of collection
Declaration
public PageDataCollection Copy()
Returns
Type | Description |
---|---|
PageDataCollection | Copied collection |
CopyTo(PageData[], Int32)
Copies the elements to an PageData Array, starting at a particular Array index.
Declaration
public void CopyTo(PageData[] array, int index)
Parameters
Type | Name | Description |
---|---|---|
PageData[] | array | The one-dimensional PageData Array that is the destination of the elements copied. |
System.Int32 | index | The zero-based index in array at which copying begins. |
Exists(PageReference)
Check if page with reference exists in collection
Declaration
public bool Exists(PageReference page)
Parameters
Type | Name | Description |
---|---|---|
PageReference | page | The reference to find |
Returns
Type | Description |
---|---|
System.Boolean | Returns false when reference not found |
Exists(PageReference, String)
Check if page with reference exists in collection
Declaration
public bool Exists(PageReference page, string languageBranch)
Parameters
Type | Name | Description |
---|---|---|
PageReference | page | The reference to find |
System.String | languageBranch | The language branch to search for |
Returns
Type | Description |
---|---|
System.Boolean | Returns false when reference not found |
Find(PageReference)
Find page reference in collection
Declaration
public int Find(PageReference page)
Parameters
Type | Name | Description |
---|---|---|
PageReference | page | The reference to find |
Returns
Type | Description |
---|---|
System.Int32 | Returns -1 when reference not found |
Find(PageReference, String)
Find page reference in collection with a specific language branch
Declaration
public int Find(PageReference page, string languageBranch)
Parameters
Type | Name | Description |
---|---|---|
PageReference | page | The reference to find |
System.String | languageBranch | The language branch to search for |
Returns
Type | Description |
---|---|
System.Int32 | Returns -1 when reference not found |
GetEnumerator()
Returns enumerator for this collection
Declaration
public IEnumerator<PageData> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<PageData> |
IndexOf(PageData)
Determines the index of a specific item in the PageDataCollection.
Declaration
public int IndexOf(PageData item)
Parameters
Type | Name | Description |
---|---|---|
PageData | item | The PageData item to locate in the PageDataCollection. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
IndexOf(Object)
Determines the index of a specific item in the PageDataCollection.
Declaration
public int IndexOf(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The System.Object to locate in the PageDataCollection. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
Insert(Int32, PageData)
Insert new page at given position
Declaration
public void Insert(int index, PageData page)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index to insert page |
PageData | page | Page to insert |
Insert(Int32, Object)
Inserts an item, which must be of type PageData, in the PageDataCollection at the specified index.
Declaration
public void Insert(int index, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which |
System.Object | value | The PageData instance to insert into the PageDataCollection. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
Remove(PageData)
Removes the first occurrence of a specific page from the PageDataCollection.
Declaration
public bool Remove(PageData page)
Parameters
Type | Name | Description |
---|---|---|
PageData | page | The page to remove from the PageDataCollection. |
Returns
Type | Description |
---|---|
System.Boolean | true if page was successfully removed from the PageDataCollection; otherwise, false. This method also returns false if page is not found in the collection. |
Remove(Object)
Removes the first occurrence of a specific object from the PageDataCollection.
Declaration
public void Remove(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The System.Object to remove from the PageDataCollection. |
RemoveAt(Int32)
Remove page from collection
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Remove at index |
RemoveRange(Int32, Int32)
Remove multiple pages from collection
Declaration
public void RemoveRange(int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Start removing at index |
System.Int32 | count | Number of pages to remove |
ShallowCopy()
Make a shallow copy of collection
Declaration
public PageDataCollection ShallowCopy()
Returns
Type | Description |
---|---|
PageDataCollection | Copied collection |
Sort(IComparer<PageData>)
Sorts all the elements in the collection
Declaration
public void Sort(IComparer<PageData> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IComparer<PageData> | comparer |
ToRawPageArray()
Returns array of RawPage elements
Declaration
[Obsolete("RawPage instances are now created using IRawContentRetriever.")]
public RawPage[] ToRawPageArray()
Returns
Type | Description |
---|---|
RawPage[] |
Explicit Interface Implementations
ICollection.CopyTo(Array, Int32)
Copies the elements to an Array, starting at a particular Array index.
Declaration
void ICollection.CopyTo(Array array, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Array | array | The one-dimensional Array that is the destination of the elements copied. |
System.Int32 | index | The zero-based index in array at which copying begins. |
IEnumerable.GetEnumerator()
Retrive enumerator
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |
IList.get_Item(Int32)
Declaration
object IList.get_Item(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Returns
Type | Description |
---|---|
System.Object |
IList.Item[Int32]
Gets or sets the PageData instance at the specified index.
Declaration
object IList.this[] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Returns
Type | Description |
---|---|
System.Object |
IList.set_Item(Int32, Object)
Declaration
void IList.set_Item(int index, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | |
System.Object | value |