In This Article

LogicalTreeNodeCollection Class

Provides a base collection class for objects that implement ILogicalTreeNode.

public class LogicalTreeNodeCollection : MarshalByRefDisposableObject, IDisposable
Inheritance:
object MarshalByRefObject MarshalByRefDisposableObject object
Derived:
UIElementCollection
Implements:
IDisposable

Constructors

LogicalTreeNodeCollection(ILogicalTreeNode?)

Provides a base collection class for objects that implement ILogicalTreeNode.

public LogicalTreeNodeCollection(ILogicalTreeNode? owner)
Parameter Type Description
owner ILogicalTreeNode

The owner of the collection.

Properties

AutoAssignParent

Indicates whether to automatically assign the parent of child objects to be the owner of the collection.

protected bool AutoAssignParent { get; set; }

Property Value

bool:

true if the parent of child objects should be assigned; otherwise, false.

Count

Gets the number of elements contained in the ICollection<T>.

public virtual int Count { get; }

Property Value

int:

The number of elements contained in the ICollection<T>.

InnerList

The list of items contained in the collection instance.

protected List<ILogicalTreeNode> InnerList { get; }

Property Value

List<ILogicalTreeNode>

IsReadOnly

Gets a value indicating whether the ICollection<T> is read-only.

public virtual bool IsReadOnly { get; }

Property Value

bool:

true if the ICollection<T> is read-only; otherwise, false.

OwnerCore

The ILogicalTreeNode that is the owner of the collection.

protected ILogicalTreeNode? OwnerCore { get; set; }

Property Value

ILogicalTreeNode

Methods

AddCore(ILogicalTreeNode)

Adds an item to the ICollection<T>.

protected int AddCore(ILogicalTreeNode value)
Parameter Type Description
value ILogicalTreeNode

Returns

int

Exceptions

Type Condition
NotSupportedException

The ICollection<T> is read-only.

ClearCore()

Removes all items from the ICollection<T>.

protected void ClearCore()

Exceptions

Type Condition
NotSupportedException

The ICollection<T> is read-only.

Contains(ILogicalTreeNode)

Determines whether the ICollection<T> contains a specific value.

public virtual bool Contains(ILogicalTreeNode value)
Parameter Type Description
value ILogicalTreeNode

Returns

bool:

true if item is found in the ICollection<T>; otherwise, false.

CopyTo(ILogicalTreeNode[], int)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

public virtual void CopyTo(ILogicalTreeNode[] array, int arrayIndex)
Parameter Type Description
array ILogicalTreeNode[]

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Exceptions

Type Condition
ArgumentNullException

array is null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException

The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

Dispose(bool)

Releases the unmanaged resources used by the object and optionally releases the managed resources.

protected override void Dispose(bool disposing)
Parameter Type Description
disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

This method is called by the public Dispose method and the Finalize method. Dispose invokes this method with the disposing parameter set to true. Finalize invokes this method with disposing set to false.

DisposeAllChildObjects()

Disposes each child object in the collection that implements IDisposable.

protected void DisposeAllChildObjects()

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<ILogicalTreeNode> GetEnumerator()

Returns

IEnumerator<ILogicalTreeNode>:

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

IndexOf(ILogicalTreeNode)

Determines the index of a specific item in the IList<T>.

public virtual int IndexOf(ILogicalTreeNode value)
Parameter Type Description
value ILogicalTreeNode

Returns

int:

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

InsertCore(int, ILogicalTreeNode)

Inserts an item to the IList<T> at the specified index.

protected void InsertCore(int index, ILogicalTreeNode value)
Parameter Type Description
index int

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

value ILogicalTreeNode

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

Exceptions

Type Condition
ArgumentOutOfRangeException

index is not a valid index in the IList<T>.

NotSupportedException

The IList<T> is read-only.

OnObjectAdded(int, ILogicalTreeNode)

Performs additional custom processes after an object is added to the collection.

protected virtual void OnObjectAdded(int index, ILogicalTreeNode value)
Parameter Type Description
index int

The zero-based index at which the object was inserted.

value ILogicalTreeNode

The object that was inserted.

Remarks

The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified object is added.

OnObjectAdding(int, ILogicalTreeNode)

Performs additional custom processes before an object is added to the collection.

protected virtual void OnObjectAdding(int index, ILogicalTreeNode value)
Parameter Type Description
index int

The zero-based index at which the object was inserted.

value ILogicalTreeNode

The object that was inserted.

Remarks

The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified object is added.

OnObjectRemoved(int, ILogicalTreeNode)

Performs additional custom processes after an object is removed from the collection.

protected virtual void OnObjectRemoved(int index, ILogicalTreeNode value)
Parameter Type Description
index int

The zero-based index from which the object was removed.

value ILogicalTreeNode

The object that was removed.

Remarks

The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified object is removed.

OnObjectRemoving(int, ILogicalTreeNode)

Performs additional custom processes before an object is removed from the collection.

protected virtual void OnObjectRemoving(int index, ILogicalTreeNode value)
Parameter Type Description
index int

The zero-based index from which the object was removed.

value ILogicalTreeNode

The object that was removed.

Remarks

The default implementation of this method is intended to be overridden by a derived class to perform some action before the specified object is removed.

OnValidate(ILogicalTreeNode, int)

Performs additional custom processes when validating a value.

protected virtual void OnValidate(ILogicalTreeNode value, int existingIndex)
Parameter Type Description
value ILogicalTreeNode

The object to validate.

existingIndex int

The index within the collection of the object that would be replaced by the value.

Remarks

The default implementation of this method determines whether value is null, and if so, throws ArgumentNullException. It is intended to be overridden by a derived class to perform additional action when the specified element is validated.

RemoveAtCore(int)

Removes the IList<T> item at the specified index.

protected void RemoveAtCore(int index)
Parameter Type Description
index int

The zero-based index of the item to remove.

Exceptions

Type Condition
ArgumentOutOfRangeException

index is not a valid index in the IList<T>.

NotSupportedException

The IList<T> is read-only.

RemoveCore(ILogicalTreeNode)

Removes the first occurrence of a specific object from the ICollection<T>.

protected bool RemoveCore(ILogicalTreeNode value)
Parameter Type Description
value ILogicalTreeNode

Returns

bool:

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

Exceptions

Type Condition
NotSupportedException

The ICollection<T> is read-only.

SetCore(int, ILogicalTreeNode)

Sets a value at the specified index in the collection.

protected void SetCore(int index, ILogicalTreeNode value)
Parameter Type Description
index int

The zero-based index of the object to set.

value ILogicalTreeNode

The object to add to the collection.

Events

ObjectAdded

Occurs after an object is added to the collection.

public event LogicalTreeNodeCollectionEventHandler? ObjectAdded

Event Type

LogicalTreeNodeCollectionEventHandler

ObjectAdding

Occurs before an object is added to the collection.

public event LogicalTreeNodeCollectionEventHandler? ObjectAdding

Event Type

LogicalTreeNodeCollectionEventHandler

ObjectRemoved

Occurs after an object is removed from the collection.

public event LogicalTreeNodeCollectionEventHandler? ObjectRemoved

Event Type

LogicalTreeNodeCollectionEventHandler

ObjectRemoving

Occurs before an object is removed from the collection.

public event LogicalTreeNodeCollectionEventHandler? ObjectRemoving

Event Type

LogicalTreeNodeCollectionEventHandler

Inherited Members

Extension Methods