November Happy Hour will be moved to Thursday December 5th.

Class CategoryCollection

Represents a collection of Category instances.

Inheritance
System.Object
CategoryCollection
Implements
System.Collections.Generic.IList<Category>
System.Collections.Generic.ICollection<Category>
System.Collections.Generic.IEnumerable<Category>
System.Collections.IList
System.Collections.ICollection
System.Collections.IEnumerable
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.DataAbstraction
Assembly: EPiServer.dll
Version: 10.10.4
Syntax
public class CategoryCollection : IList<Category>, ICollection<Category>, IEnumerable<Category>, IReadOnly<CategoryCollection>, IReadOnly, IList, ICollection, IEnumerable
Remarks

You can use this class to iterate through categories from a given level, or add and delete categories. See the Category class for more information.

Constructors

CategoryCollection()

Initializes a new instance of the CategoryCollection class without an owner.

Declaration
public CategoryCollection()

CategoryCollection(Category)

Initializes a new instance of the CategoryCollection class.

Declaration
public CategoryCollection(Category parent)
Parameters
Type Name Description
Category parent

The parent category that the categories in this collection will be children of.

Properties

Count

Gets the number of categories contained in the CategoryCollection.

Declaration
public virtual int Count { get; }
Property Value
Type Description
System.Int32

IsReadOnly

Gets a value indicating whether the CategoryCollection is read-only.

Declaration
public virtual bool IsReadOnly { get; }
Property Value
Type Description
System.Boolean

Item[Int32]

Gets or sets the category at the specified index.

Declaration
public virtual Category this[int index] { get; set; }
Parameters
Type Name Description
System.Int32 index

The index of the Category to access.

Property Value
Type Description
Category

The Category at the provided index.

Items

Gets direct access to a list of the contained categories.

Declaration
protected IList<Category> Items { get; }
Property Value
Type Description
System.Collections.Generic.IList<Category>

Methods

Add(Category)

Adds a category to the CategoryCollection.

Declaration
public virtual void Add(Category item)
Parameters
Type Name Description
Category item

The category to add to the CategoryCollection.

AddRange(IEnumerable<Category>)

Adds a range of categories to the CategoryCollection.

Declaration
public virtual void AddRange(IEnumerable<Category> items)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<Category> items

The categories to add.

Exceptions
Type Condition
System.ArgumentNullException

items

Clear()

Removes all categories from the CategoryCollection.

Declaration
public virtual void Clear()

Contains(Category)

Determines whether the CategoryCollection contains a specific category.

Declaration
public virtual bool Contains(Category item)
Parameters
Type Name Description
Category item

The category to locate in the CategoryCollection.

Returns
Type Description
System.Boolean

true if the item is found in the CategoryCollection; otherwise, false.

CreateWritableClone()

Declaration
public virtual CategoryCollection CreateWritableClone()
Returns
Type Description
CategoryCollection

GetEnumerator()

Returns an enumerator that iterates through all the categories in the collection.

Declaration
public IEnumerator<Category> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<Category>

An enumerator that can be used to iterate through the collection.

IndexOf(Category)

Determines the index of a specific category in the CategoryCollection.

Declaration
public virtual int IndexOf(Category item)
Parameters
Type Name Description
Category item

The category to locate in the CategoryCollection.

Returns
Type Description
System.Int32

The index of the item if found in the list; otherwise, -1.

Insert(Int32, Category)

Inserts an item to the CategoryCollection at the specified index.

Declaration
public virtual void Insert(int index, Category item)
Parameters
Type Name Description
System.Int32 index

The zero-based index at which item should be inserted.

Category item

The object to insert into the CategoryCollection.

MakeReadOnly()

Declaration
public virtual void MakeReadOnly()

Remove(Category)

Removes the first occurrence of a specific category from the CategoryCollection.

Declaration
public virtual bool Remove(Category item)
Parameters
Type Name Description
Category item

The category to remove from the CategoryCollection.

Returns
Type Description
System.Boolean

true if item was successfully removed from the CategoryCollection; otherwise, false. This method also returns false if item is not found in the original CategoryCollection.

RemoveAt(Int32)

Removes the category at the specified index in the CategoryCollection.

Declaration
public virtual void RemoveAt(int index)
Parameters
Type Name Description
System.Int32 index

The zero-based index of the category to remove.

ThrowIfReadOnly()

Throws an exception if the CategoryCollection is read only.

Declaration
protected void ThrowIfReadOnly()

Explicit Interface Implementations

IReadOnly.CreateWritableClone()

Declaration
object IReadOnly.CreateWritableClone()
Returns
Type Description
System.Object

ICollection<Category>.CopyTo(Category[], Int32)

Declaration
void ICollection<Category>.CopyTo(Category[] array, int arrayIndex)
Parameters
Type Name Description
Category[] array
System.Int32 arrayIndex

ICollection.CopyTo(Array, Int32)

Declaration
void ICollection.CopyTo(Array array, int index)
Parameters
Type Name Description
System.Array array
System.Int32 index

ICollection.IsSynchronized

Declaration
bool ICollection.IsSynchronized { get; }
Returns
Type Description
System.Boolean

ICollection.SyncRoot

Declaration
object ICollection.SyncRoot { get; }
Returns
Type Description
System.Object

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

IList.Add(Object)

Declaration
int IList.Add(object value)
Parameters
Type Name Description
System.Object value
Returns
Type Description
System.Int32

IList.Contains(Object)

Declaration
bool IList.Contains(object value)
Parameters
Type Name Description
System.Object value
Returns
Type Description
System.Boolean

IList.get_Item(Int32)

Declaration
object IList.get_Item(int index)
Parameters
Type Name Description
System.Int32 index
Returns
Type Description
System.Object

IList.IndexOf(Object)

Declaration
int IList.IndexOf(object value)
Parameters
Type Name Description
System.Object value
Returns
Type Description
System.Int32

IList.Insert(Int32, Object)

Declaration
void IList.Insert(int index, object value)
Parameters
Type Name Description
System.Int32 index
System.Object value

IList.IsFixedSize

Declaration
bool IList.IsFixedSize { get; }
Returns
Type Description
System.Boolean

IList.Item[Int32]

Declaration
object IList.this[] { get; set; }
Parameters
Type Name Description
System.Int32 index
Returns
Type Description
System.Object

IList.Remove(Object)

Declaration
void IList.Remove(object value)
Parameters
Type Name Description
System.Object value

IList.set_Item(Int32, Object)

Declaration
void IList.set_Item(int index, object value)
Parameters
Type Name Description
System.Int32 index
System.Object value

Implements

System.Collections.Generic.IList<T>
System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IList
System.Collections.ICollection
System.Collections.IEnumerable

Extension Methods