Show / Hide Table of Contents

Class TreeNode<T>

Class representing a node of a tree.

Inheritance
System.Object
TreeNode<T>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace:Extend
Assembly:Extend.dll
Syntax
public class TreeNode<T> : ITreeNode<T>, IDisposable, IEnumerable<ITreeNode<T>>, IEnumerable
Type Parameters
Name Description
T The type of the value of the node.

Constructors

| Improve this Doc View Source

TreeNode()

Creates a new instance of the TreeNode<T> class.

Declaration
public TreeNode()
| Improve this Doc View Source

TreeNode(T, ITreeNode<T>)

Creates a new instance of the TreeNode<T> class.

Declaration
public TreeNode(T value, ITreeNode<T> parent)
Parameters
Type Name Description
T value

The value of the node.

ITreeNode<T><T> parent

The parent of the node.

| Improve this Doc View Source

TreeNode(T, ITreeNode<T>, ITreeNodeCollection<T>)

Creates a new instance of the TreeNode<T> class.

Declaration
public TreeNode(T value, ITreeNode<T> parent = null, ITreeNodeCollection<T> children = null)
Parameters
Type Name Description
T value

The value of the node.

ITreeNode<T><T> parent

The parent of the node.

ITreeNodeCollection<T><T> children

The children of the node.

| Improve this Doc View Source

TreeNode(T, ITreeNodeCollection<T>)

Creates a new instance of the TreeNode<T> class.

Declaration
public TreeNode(T value, ITreeNodeCollection<T> children)
Parameters
Type Name Description
T value

The value of the node.

ITreeNodeCollection<T><T> children

The children of the node.

| Improve this Doc View Source

TreeNode(ITreeNode<T>)

Creates a new instance of the TreeNode<T> class.

Declaration
public TreeNode(ITreeNode<T> parent)
Parameters
Type Name Description
ITreeNode<T><T> parent

The parent of the node.

| Improve this Doc View Source

TreeNode(ITreeNodeCollection<T>)

Creates a new instance of the TreeNode<T> class.

Declaration
public TreeNode(ITreeNodeCollection<T> children)
Parameters
Type Name Description
ITreeNodeCollection<T><T> children

The children of the node.

Properties

| Improve this Doc View Source

Ancestors

Gets an enumeration of all tree nodes which are above the current node in the tree.

Declaration
public IEnumerable<ITreeNode<T>> Ancestors { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<T><ITreeNode<T><T>>

An enumeration of all tree nodes which are above the current node in the tree.

| Improve this Doc View Source

AncestorsTraversalDirection

Gets or sets the ancestors traversal direction.

Declaration
public TreeTraversalDirection AncestorsTraversalDirection { get; set; }
Property Value
Type Description
TreeTraversalDirection

The ancestors traversal direction.

Implements
ITreeNode<T>.AncestorsTraversalDirection
| Improve this Doc View Source

Children

Gets or sets the children of the node.

Declaration
public ITreeNodeCollection<T> Children { get; set; }
Property Value
Type Description
ITreeNodeCollection<T><T>

The children of the node.

Implements
ITreeNode<T>.Children
| Improve this Doc View Source

Depth

Gets the depth of the node.

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

The depth of the node.

Implements
ITreeNode<T>.Depth
| Improve this Doc View Source

Descendants

Gets an enumeration of all tree nodes which are below the current node in the tree.

Declaration
public IEnumerable<ITreeNode<T>> Descendants { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<T><ITreeNode<T><T>>

An enumeration of all tree nodes which are below the current node in the tree.

Implements
ITreeNode<T>.Descendants
| Improve this Doc View Source

DescendantsTraversalDirection

Gets or sets the descendants traversal direction.

Declaration
public TreeTraversalDirection DescendantsTraversalDirection { get; set; }
Property Value
Type Description
TreeTraversalDirection

The descendants traversal direction.

Implements
ITreeNode<T>.DescendantsTraversalDirection
| Improve this Doc View Source

DisposeTraversalDirection

Gets or sets the dispose traversal direction.

Declaration
public TreeTraversalDirection DisposeTraversalDirection { get; set; }
Property Value
Type Description
TreeTraversalDirection

The dispose traversal direction.

Implements
ITreeNode<T>.DisposeTraversalDirection
| Improve this Doc View Source

HasChildren

Gets a value indicating whether the node has any children or not.

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

A value indicating whether the node has any children or not.

Implements
ITreeNode<T>.HasChildren
| Improve this Doc View Source

HasParent

Gets a value indicating whether the node has a parent or not.

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

A value indicating whether the node has a parent or not.

Implements
ITreeNode<T>.HasParent
| Improve this Doc View Source

Parent

Gets or sets the parent of the node.

Declaration
public ITreeNode<T> Parent { get; set; }
Property Value
Type Description
ITreeNode<T><T>

The parent of the node.

Implements
ITreeNode<T>.Parent
Remarks

Detaches the node from it's old parent and attaches it to it's new parent.

| Improve this Doc View Source

Root

Gets the root of the tree.

Declaration
public ITreeNode<T> Root { get; }
Property Value
Type Description
ITreeNode<T><T>

The root of the tree.

Implements
ITreeNode<T>.Root
| Improve this Doc View Source

SearchTraversalDirection

Gets or sets the search traversal direction.

Declaration
public TreeTraversalDirection SearchTraversalDirection { get; set; }
Property Value
Type Description
TreeTraversalDirection

The search traversal direction.

Implements
ITreeNode<T>.SearchTraversalDirection
| Improve this Doc View Source

TraversalDirection

Gets or sets the traversal direction used to enumerate the nodes.

Declaration
public TreeTraversalDirection TraversalDirection { get; set; }
Property Value
Type Description
TreeTraversalDirection

The traversal direction used to enumerate the nodes.

Implements
ITreeNode<T>.TraversalDirection
| Improve this Doc View Source

Value

Gets or sets the value of the node.

Declaration
public T Value { get; set; }
Property Value
Type Description
T

The value of the node.

Implements
ITreeNode<T>.Value

Methods

| Improve this Doc View Source

Add(T)

Adds the given value as child to the node.

Declaration
public ITreeNode<T> Add(T value)
Parameters
Type Name Description
T value

The value to add.

Returns
Type Description
ITreeNode<T><T>

Returns the added node.

Implements
ITreeNode<T>.Add(T)
| Improve this Doc View Source

Add(ITreeNode<T>)

Adds the given node as child to the node, if it is not already a child of the node.

Declaration
public ITreeNode<T> Add(ITreeNode<T> node)
Parameters
Type Name Description
ITreeNode<T><T> node

The node to add.

Returns
Type Description
ITreeNode<T><T>

Returns the added node.

Implements
ITreeNode<T>.Add(ITreeNode<T>)
| Improve this Doc View Source

Dispose()

Release all resources hold by the node.

Declaration
public void Dispose()
Implements
System.IDisposable.Dispose()
| Improve this Doc View Source

Dispose(Boolean)

Releases the managed and unmanaged resource hold by the node.

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
System.Boolean disposing

A value of true to release managed resources, false to release unmanaged resources.

| Improve this Doc View Source

Finalize()

Destructs the tree node..

Declaration
protected void Finalize()
| Improve this Doc View Source

FindNode(T)

Gets the nodes with the given value.

Declaration
public IEnumerable<ITreeNode<T>> FindNode(T value)
Parameters
Type Name Description
T value

The value to search.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><ITreeNode<T><T>>

Returns the nodes with the given value.

Implements
ITreeNode<T>.FindNode(T)
| Improve this Doc View Source

FindNode(Func<ITreeNode<T>, Boolean>)

Gets the nodes which matches the given predicate.

Declaration
public virtual IEnumerable<ITreeNode<T>> FindNode(Func<ITreeNode<T>, bool> predicate)
Parameters
Type Name Description
System.Func<T, TResult><ITreeNode<T><T>, System.Boolean> predicate

The predicate.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><ITreeNode<T><T>>

Returns the nodes which matches the given predicate.

Implements
ITreeNode<T>.FindNode(Func<ITreeNode<T>, Boolean>)
Remarks

Starts the search at the current tree node and traverses down the tree (Direction based on

SearchTraversalDirection).

Exceptions
Type Condition
System.ArgumentNullException

predicate can not be null.

| Improve this Doc View Source

FindValue(Func<ITreeNode<T>, Boolean>)

Gets the values which matches the given predicate.

Declaration
public virtual IEnumerable<T> FindValue(Func<ITreeNode<T>, bool> predicate)
Parameters
Type Name Description
System.Func<T, TResult><ITreeNode<T><T>, System.Boolean> predicate

The predicate.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><T>

Returns the values which matches the given predicate.

Implements
ITreeNode<T>.FindValue(Func<ITreeNode<T>, Boolean>)
Remarks

Starts the search at the current tree node and traverses down the tree (Direction based on

SearchTraversalDirection).

Exceptions
Type Condition
System.ArgumentNullException

predicate can not be null.

| Improve this Doc View Source

GetEnumerator()

Returns an enumerator that iterates through the collection.

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

A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection.

Implements
System.Collections.Generic.IEnumerable<T>.GetEnumerator()
| Improve this Doc View Source

SetAllDirections(TreeTraversalDirection)

Sets all directions (DisposeTraversalDirection, SearchTraversalDirection,

AncestorsTraversalDirection, DescendantsTraversalDirection).

Declaration
public void SetAllDirections(TreeTraversalDirection direction)
Parameters
Type Name Description
TreeTraversalDirection direction

The new direction.

Implements
ITreeNode<T>.SetAllDirections(TreeTraversalDirection)
| Improve this Doc View Source

SetParent(ITreeNode<T>, Boolean, Boolean)

Sets the parent of the tree node.

Declaration
public void SetParent(ITreeNode<T> parent, bool attacheToNewParent = true, bool detachFromOldParent = true)
Parameters
Type Name Description
ITreeNode<T><T> parent

The new parent.

System.Boolean attacheToNewParent

A value determining whether the node should add it self to the children of the new parent or not.

System.Boolean detachFromOldParent

A value indicating whether the node should detach itself from it's old parent or not.

Implements
ITreeNode<T>.SetParent(ITreeNode<T>, Boolean, Boolean)
| Improve this Doc View Source

ToString()

Returns a string that represents the current object.

Declaration
public override string ToString()
Returns
Type Description
System.String

A string that represents the current object.

Overrides
System.Object.ToString()

Explicit Interface Implementations

| Improve this Doc View Source

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through the collection.

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

A System.Collections.IEnumerator that can be used to iterate through the collection.

Implements
System.Collections.IEnumerable.GetEnumerator()

Extension Methods

IEnumerableTEx.Intersect<TSource, TKey>(IEnumerable<TSource>, IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>)
IEnumerableTEx.GetEqualItemsFromStart<T>(IEnumerable<T>, IEnumerable<T>, IEqualityComparer<T>)
IEnumerableTEx.Except<TSource, TKey>(IEnumerable<TSource>, IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>)
IEnumerableTEx.Partition<T>(IEnumerable<T>, Int32)
IEnumerableTEx.WithIndex<T>(IEnumerable<T>)
IEnumerableTEx.Prepend<T>(IEnumerable<T>, T)
IEnumerableTEx.Append<T>(IEnumerable<T>, T)
IEnumerableTEx.GetRandomItem<T>(IEnumerable<T>)
IEnumerableTEx.WhereNot<T>(IEnumerable<T>, ISpecification<T>)
IEnumerableTEx.Where<T>(IEnumerable<T>, ISpecification<T>)
IEnumerableTEx.SpecificationForItems<T>(IEnumerable<T>, Func<T, Boolean>, String)
IEnumerableTEx.EnsureNotNull<T>(IEnumerable<T>)
IEnumerableTEx.IsNullOrEmpty<T>(IEnumerable<T>)
IEnumerableTEx.ContainsAll<T>(IEnumerable<T>, T[])
IEnumerableTEx.ContainsAll<T>(IEnumerable<T>, IEnumerable<T>)
IEnumerableTEx.ContainsAny<T>(IEnumerable<T>, T[])
IEnumerableTEx.ContainsAny<T>(IEnumerable<T>, IEnumerable<T>)
IEnumerableTEx.ForEach<T>(IEnumerable<T>, Action<T>)
IEnumerableTEx.ForEach<T>(IEnumerable<T>, Action<T, Int32>)
IEnumerableTEx.ForEachReverse<T>(IEnumerable<T>, Action<T>)
IEnumerableTEx.NotAny<T>(IEnumerable<T>)
IEnumerableTEx.NotAny<T>(IEnumerable<T>, Func<T, Boolean>)
IEnumerableTEx.AnyAndNotNull<T>(IEnumerable<T>)
IEnumerableTEx.AnyAndNotNull<T>(IEnumerable<T>, Func<T, Boolean>)
IEnumerableTEx.StringJoin<T>(IEnumerable<T>, String)
IEnumerableTEx.StringJoin<T>(IEnumerable<T>, Func<T, String>, String)
IEnumerableTEx.WhereIf<T>(IEnumerable<T>, Boolean, Func<T, Boolean>)
IEnumerableTEx.WhereIf<T>(IEnumerable<T>, Boolean, Func<T, Int32, Boolean>)
IEnumerableTEx.Randomize<T>(IEnumerable<T>)
IEnumerableTEx.Distinct<T, TKey>(IEnumerable<T>, Func<T, TKey>)
IEnumerableTEx.ToObservableCollection<T>(IEnumerable<T>)
IEnumerableTEx.Many<T>(IEnumerable<T>, Func<T, Boolean>)
IEnumerableTEx.Many<T>(IEnumerable<T>)
IEnumerableTEx.MinimumOf<T>(IEnumerable<T>, Int32, Func<T, Boolean>)
IEnumerableTEx.MinimumOf<T>(IEnumerable<T>, Int32)
IEnumerableTEx.TakeUntil<T>(IEnumerable<T>, Func<T, Boolean>)
ObjectEx.SatisfiesWithMessages<T>(T, ISpecification<T>)
ObjectEx.Specification<T>(T, Func<T, Boolean>, String)
ObjectEx.GetNameChain<TObject, TMember>(TObject, Expression<Func<TObject, TMember>>)
ObjectEx.GetNameChain<TObject, TMember>(TObject, Expression<Func<TMember>>)
ObjectEx.Swap<T>(Object, ref T, ref T)
ObjectEx.ToSingleItemArray<T>(T)
ObjectEx.Maximum<TSource>(TSource, TSource[])
ObjectEx.Maximum<TSource, TResult>(TSource, Func<TSource, TResult>, TSource[])
ObjectEx.Minimum<TSource>(TSource, TSource[])
ObjectEx.Minimum<TSource, TResult>(TSource, Func<TSource, TResult>, TSource[])
ObjectEx.Satisfies<T>(T, ISpecification<T>)
ObjectEx.IfNull<T>(T, T)
ObjectEx.ThrowIfNull<TObject>(TObject, Expression<Func<TObject>>, String)
ObjectEx.ThrowIfNull<TObject>(TObject, String, String)
ObjectEx.GetName<TObject, TMember>(TObject, Expression<Func<TObject, TMember>>)
ObjectEx.GetName<TObject, TMember>(TObject, Expression<Func<TMember>>)
ObjectEx.IsNull(Object)
ObjectEx.IsNotNull(Object)
ObjectEx.As<T>(Object)
ObjectEx.Chain<T>(T, Action<T>)
ObjectEx.RefEquals(Object, Object)
ObjectEx.Coalesce<T>(T, T[])
ObjectEx.Coalesce<T>(T, T)
ObjectEx.CoalesceOrDefault<T>(T, T, T[])
ObjectEx.CoalesceOrDefault<T>(T, Func<T>, T[])
ObjectEx.ExecuteSafe<T>(T, Action<T>)
ObjectEx.ExecuteSafe<T, TResult>(T, Func<T, TResult>)
ObjectEx.ToBoolean(Object)
ObjectEx.ToBoolean(Object, IFormatProvider)
ObjectEx.ToByte(Object)
ObjectEx.ToByte(Object, IFormatProvider)
ObjectEx.ToChar(Object)
ObjectEx.ToChar(Object, IFormatProvider)
ObjectEx.ToDateTime(Object)
ObjectEx.ToDateTime(Object, IFormatProvider)
ObjectEx.ToDecimal(Object)
ObjectEx.ToDecimal(Object, IFormatProvider)
ObjectEx.ToDouble(Object)
ObjectEx.ToDouble(Object, IFormatProvider)
ObjectEx.ToInt32(Object)
ObjectEx.ToInt32(Object, IFormatProvider)
ObjectEx.ToInt16(Object)
ObjectEx.ToInt16(Object, IFormatProvider)
ObjectEx.ToInt64(Object)
ObjectEx.ToInt64(Object, IFormatProvider)
ObjectEx.IsIn<T>(T, T[])
ObjectEx.IsIn<T>(T, IEnumerable<T>)
ObjectEx.IsNotIn<T>(T, T[])
ObjectEx.IsNotIn<T>(T, IEnumerable<T>)
ObjectEx.IsDefault<T>(T)
DecimalEx.Sum<TSource>(TSource, Func<TSource, Decimal>, TSource[])
DecimalEx.Sum<TSource>(TSource, Func<TSource, Nullable<Decimal>>, TSource[])
DoubleEx.Sum<TSource>(TSource, Func<TSource, Double>, TSource[])
DoubleEx.Sum<TSource>(TSource, Func<TSource, Nullable<Double>>, TSource[])
Int32Ex.Sum<TSource>(TSource, Func<TSource, Int32>, TSource[])
Int32Ex.Sum<TSource>(TSource, Func<TSource, Nullable<Int32>>, TSource[])
Int64Ex.Sum<TSource>(TSource, Func<TSource, Int64>, TSource[])
Int64Ex.Sum<TSource>(TSource, Func<TSource, Nullable<Int64>>, TSource[])
  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2016 Microsoft
Generated by DocFX