EntityTreeBuildExtensionsBuildTNode, TItem, TSource(TNode, IEnumerableTSource, FuncTSource, TItem, FuncTSource, Guid, NullableInt32) Method

Build tree from parent/root node using source sequence of arbitrary type. Uses functions to retrieve parent ID and item from source objects.

Definition

Namespace: MobileTrack.Common.Models.TreeViews.ItemTree.EntityTree
Assembly: MobileTrack.Common (in MobileTrack.Common.dll) Version: 0.7+45c8d9adb5970d727cceec44a5ed61aea0016e50
public static void Build<TNode, TItem, TSource>(
	this TNode parentNode,
	IEnumerable<TSource> sourceItems,
	Func<TSource, TItem> getItem,
	Func<TSource, Guid> getParentId,
	int? maxRelativeDepth = null
)
where TNode : EntityTreeNode<TNode, TItem>
where TItem : IIdLabel

Parameters

parentNode  TNode
Parent/root destination node
sourceItems  IEnumerableTSource
Sequence of source objects
getItem  FuncTSource, TItem
Get item from source object
getParentId  FuncTSource, Guid
Get parent Id from source object
maxRelativeDepth  NullableInt32  (Optional)
Maximum depth to enter. This is required, as this method is recursive and the danger of a StackOverflowException is always there.

Type Parameters

TNode
Node type
TItem
Model type that the TNode is a container for.
TSource
Source type of the items to build the tree for. Usually, the TItem is a part of TSource and provided using the getItem method lambda.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type TNode. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also