LogicalTreeNodeCollection Class
Provides a base collection class for objects that implement ILogicalTreeNode.
public class LogicalTreeNodeCollection : DisposableObject, IDisposable
- Inheritance:
- object MarshalByRefObject DisposableObject object
- Implements:
- IDisposable
Constructors
LogicalTreeNodeCollection(ILogicalTreeNode)
Initializes a new instance of the LogicalTreeNodeCollection
class.
public LogicalTreeNodeCollection(ILogicalTreeNode owner)
Parameter | Type | Description |
---|---|---|
owner | ILogicalTreeNode | The owner of the collection. |
Properties
AutoAssignParent
Gets or sets 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 LogicalTreeNodeCollection instance.
public virtual int Count { get; }
Property Value
- int:
The number of elements contained in the LogicalTreeNodeCollection instance.
InnerList
Gets the list of items contained in the collection instance.
protected ArrayList InnerList { get; }
Property Value
IsFixedSize
Gets a value indicating whether the collection has a fixed size.
public virtual bool IsFixedSize { get; }
Property Value
- bool:
true
if the collection has a fixed size; otherwise,false
.
Remarks
A collection with a fixed size does not allow the addition or removal of elements, but it allows the modification of existing elements.
IsReadOnly
Gets a value indicating whether the collection is read-only.
public virtual bool IsReadOnly { get; }
Property Value
- bool:
true
if the collection is read-only; otherwise,false
.
IsSynchronized
Gets a value indicating whether access to the collection is synchronized (thread-safe).
public virtual bool IsSynchronized { get; }
Property Value
- bool:
true
if the collection is synchronized (thread-safe); otherwise,false
.
Remarks
To guarantee the thread safety of the collection, all operations must be done through the wrapper returned by the SyncRoot property.
OwnerCore
Gets or sets the ILogicalTreeNode that is the owner of the collection.
protected ILogicalTreeNode OwnerCore { get; set; }
Property Value
- ILogicalTreeNode:
The ILogicalTreeNode that is the owner of the collection.
SyncRoot
Gets an Object
that can be used to synchronize access to the collection.
public virtual object SyncRoot { get; }
Property Value
- object:
An
Object
that can be used to synchronize access to the collection.
Methods
AddCore(ILogicalTreeNode)
Adds an object to the end of the collection.
protected int AddCore(ILogicalTreeNode value)
Parameter | Type | Description |
---|---|---|
value | ILogicalTreeNode | The object to be added to the end of the collection. |
Returns
- int:
The collection index at which the object has been added.
ClearCore()
Removes all objects from the collection.
protected void ClearCore()
Contains(ILogicalTreeNode)
Returns whether the specified object is in the collection.
public virtual bool Contains(ILogicalTreeNode value)
Parameter | Type | Description |
---|---|---|
value | ILogicalTreeNode | The object to locate in the collection. |
Returns
- bool:
true
if the object is found in the collection; otherwise,false
.
CopyTo(Array, int)
Copies the entire collection to a compatible one-dimensional Array
,
starting at the specified index of the target array.
public virtual void CopyTo(Array array, int arrayIndex)
Parameter | Type | Description |
---|---|---|
array | Array | The one-dimensional |
arrayIndex | int | The zero-based index in |
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 |
|
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()
Retrieves an IEnumerator
object for the entire collection.
public virtual IEnumerator GetEnumerator()
Returns
- IEnumerator:
An
IEnumerator
object for the entire collection
Remarks
Enumerators are intended to be used only to read data in the collection. Enumerators cannot be used to modify the underlying collection.
The enumerator does not have exclusive access to the collection.
When an enumerator is instantiated, it takes a snapshot of the current state of the collection.
If changes are made to the collection, such as adding, modifying or deleting elements, the
snapshot gets out of sync and the enumerator throws an InvalidOperationException
.
Two enumerators instantiated from the same collection at the same time can have
different snapshots of the collection.
IndexOf(ILogicalTreeNode)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
public virtual int IndexOf(ILogicalTreeNode value)
Parameter | Type | Description |
---|---|---|
value | ILogicalTreeNode | The object to locate in the collection. |
Returns
- int:
The zero-based index of the first occurrence of the object within the entire collection, if found; otherwise,
-1
.
InsertCore(int, ILogicalTreeNode)
Inserts an object into the collection at the specified index.
protected void InsertCore(int index, ILogicalTreeNode value)
Parameter | Type | Description |
---|---|---|
index | int | The zero-based index at which the object should be inserted. |
value | ILogicalTreeNode | The object to insert. |
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.
RemoveAllOfTypeCore(Type)
Removes all objects of the specified type from the collection.
protected void RemoveAllOfTypeCore(Type type)
Parameter | Type | Description |
---|---|---|
type | Type | A Type specifying the type of objects to remove. |
RemoveAtCore(int)
Removes the element at the specified index of the collection.
protected void RemoveAtCore(int index)
Parameter | Type | Description |
---|---|---|
index | int | The zero-based index of the object to remove. |
Remarks
The elements that follow the removed element move up to occupy the vacated spot. The indexes of the elements that are moved are also updated.
RemoveCore(ILogicalTreeNode)
Removes the first occurrence of a specific object from the collection.
protected void RemoveCore(ILogicalTreeNode value)
Parameter | Type | Description |
---|---|---|
value | ILogicalTreeNode | The object to remove from the collection. |
Remarks
The elements that follow the removed element move up to occupy the vacated spot. The indexes of the elements that are moved are also updated.
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
ObjectAdding
Occurs before an object is added to the collection.
public event LogicalTreeNodeCollectionEventHandler ObjectAdding
Event Type
ObjectRemoved
Occurs after an object is removed from the collection.
public event LogicalTreeNodeCollectionEventHandler ObjectRemoved
Event Type
ObjectRemoving
Occurs before an object is removed from the collection.
public event LogicalTreeNodeCollectionEventHandler ObjectRemoving
Event Type
Inherited Members
- DisposableObject.Dispose()
- DisposableObject.VerifyNotDisposed()
- DisposableObject.IsDisposed
- DisposableObject.Disposed
- MarshalByRefObject.GetLifetimeService()
- MarshalByRefObject.InitializeLifetimeService()
- MarshalByRefObject.MemberwiseClone(bool)
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()