Class EntityCollection
Represent a collection of EntityObject that fire events when it is modified.
Inheritance
Implements
Inherited Members
Namespace: netDxf.Collections
Assembly: CADability.dll
Syntax
public class EntityCollection : IList<EntityObject>, ICollection<EntityObject>, IEnumerable<EntityObject>, IEnumerable
Constructors
| Improve this Doc View SourceEntityCollection()
Initializes a new instance of EntityCollection.
Declaration
public EntityCollection()
EntityCollection(Int32)
Initializes a new instance of EntityCollection and has the specified initial capacity.
Declaration
public EntityCollection(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | capacity | The number of items the collection can initially store. |
Properties
| Improve this Doc View SourceCount
Gets the number of EntityObject contained in the collection.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
IsReadOnly
Gets a value indicating whether the collection is read-only.
Declaration
public virtual bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Item[Int32]
Gets or sets the EntityObject at the specified index.
Declaration
public EntityObject this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index of the element to get or set. |
Property Value
| Type | Description |
|---|---|
| EntityObject | The EntityObject at the specified index. |
Methods
| Improve this Doc View SourceAdd(EntityObject)
Adds an EntityObject to the collection.
Declaration
public void Add(EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | item | The EntityObject to add to the collection. |
AddRange(IEnumerable<EntityObject>)
Adds an EntityObject list to the end of the collection.
Declaration
public void AddRange(IEnumerable<EntityObject> collection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<EntityObject> | collection | The collection whose elements should be added. |
Clear()
Removes all EntityObject from the collection.
Declaration
public void Clear()
Contains(EntityObject)
Determines whether an EntityObject is in the collection.
Declaration
public bool Contains(EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | item | The EntityObject to locate in the collection. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if item is found in the collection; otherwise, false. |
CopyTo(EntityObject[], Int32)
Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.
Declaration
public void CopyTo(EntityObject[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject[] | array | The one-dimensional System.Array that is the destination of the elements copied from the collection. The System.Array must have zero-based indexing. |
| System.Int32 | arrayIndex | The zero-based index in array at which copying begins. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<EntityObject> GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerator<EntityObject> | An enumerator that can be used to iterate through the collection. |
IndexOf(EntityObject)
Searches for the specified EntityObject and returns the zero-based index of the first occurrence within the entire collection.
Declaration
public int IndexOf(EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | item | The EntityObject to locate in the collection. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The zero-based index of the first occurrence of item within the entire collection, if found; otherwise, –1. |
Insert(Int32, EntityObject)
Inserts an EntityObject into the collection at the specified index.
Declaration
public void Insert(int index, EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index at which item should be inserted. |
| EntityObject | item | The EntityObject to insert. The value can not be null. |
OnAddItemEvent(EntityObject)
Declaration
protected virtual void OnAddItemEvent(EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | item |
OnBeforeAddItemEvent(EntityObject)
Declaration
protected virtual bool OnBeforeAddItemEvent(EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | item |
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnBeforeRemoveItemEvent(EntityObject)
Declaration
protected virtual bool OnBeforeRemoveItemEvent(EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | item |
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnRemoveItemEvent(EntityObject)
Declaration
protected virtual void OnRemoveItemEvent(EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | item |
Remove(EntityObject)
Removes the first occurrence of a specific EntityObject from the collection
Declaration
public bool Remove(EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | item | The EntityObject to remove from the collection. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if EntityObject is successfully removed; otherwise, false. |
Remove(IEnumerable<EntityObject>)
Removes the first occurrence of a specific object from the collection
Declaration
public void Remove(IEnumerable<EntityObject> items)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<EntityObject> | items | The list of objects to remove from the collection. |
RemoveAt(Int32)
Removes the EntityObject at the specified index of the collection.
Declaration
public void RemoveAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index of the EntityObject to remove. |
Events
| Improve this Doc View SourceAddItem
Declaration
public event EntityCollection.AddItemEventHandler AddItem
Event Type
| Type | Description |
|---|---|
| EntityCollection.AddItemEventHandler |
BeforeAddItem
Declaration
public event EntityCollection.BeforeAddItemEventHandler BeforeAddItem
Event Type
| Type | Description |
|---|---|
| EntityCollection.BeforeAddItemEventHandler |
BeforeRemoveItem
Declaration
public event EntityCollection.BeforeRemoveItemEventHandler BeforeRemoveItem
Event Type
| Type | Description |
|---|---|
| EntityCollection.BeforeRemoveItemEventHandler |
RemoveItem
Declaration
public event EntityCollection.RemoveItemEventHandler RemoveItem
Event Type
| Type | Description |
|---|---|
| EntityCollection.RemoveItemEventHandler |
Explicit Interface Implementations
| Improve this Doc View SourceICollection<EntityObject>.Add(EntityObject)
Declaration
void ICollection<EntityObject>.Add(EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | item |
IList<EntityObject>.Insert(Int32, EntityObject)
Declaration
void IList<EntityObject>.Insert(int index, EntityObject item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | |
| EntityObject | item |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator |