Class CategoryCollection
Represents a collection of Category instances.
Inheritance
Implements
Namespace: EPiServer.DataAbstraction
Assembly: EPiServer.dll
Version: 12.0.3Syntax
public class CategoryCollection : Object, IList<Category>, ICollection<Category>, IEnumerable<Category>, IEnumerable, IReadOnly<CategoryCollection>, IReadOnly, IList, ICollection
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 |
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 |
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 |
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 |
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 |