Hierarchy 1.0.0-alpha
This is a prerelease version of Hierarchy.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Hierarchy --version 1.0.0-alpha
NuGet\Install-Package Hierarchy -Version 1.0.0-alpha
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hierarchy" Version="1.0.0-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hierarchy --version 1.0.0-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Hierarchy, 1.0.0-alpha"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hierarchy as a Cake Addin #addin nuget:?package=Hierarchy&version=1.0.0-alpha&prerelease // Install Hierarchy as a Cake Tool #tool nuget:?package=Hierarchy&version=1.0.0-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Hierarchy
What is it
A .Net Standard library that can be used for hierarchical data
How to use
Pass in any flat list that has an identification property and a parent identification property. Here below we have a class Example which has the properties Id and ParentId.
private class Example
{
public int Id { get; set; }
public int ParentId { get; set; }
public string Name { get; set; } = "";
}
private List<Example> flatList = new()
{
new() { Id = 1, ParentId = 0, Name = "Top Level 1" },
new() { Id = 2, ParentId = 1, Name = "Top Level 1.1" },
new() { Id = 3, ParentId = 1, Name = "Top Level 1.2" },
new() { Id = 12, ParentId = 3, Name = "Top Level 1.2.1" },
new() { Id = 10, ParentId = 1, Name = "Top Level 1.3" },
new() { Id = 11, ParentId = 1, Name = "Top Level 1.4" },
new() { Id = 4, ParentId = 0, Name = "Top Level 2" },
new() { Id = 5, ParentId = 4, Name = "Top Level 2.1" },
new() { Id = 6, ParentId = 4, Name = "Top Level 2.2" },
new() { Id = 7, ParentId = 4, Name = "Top Level 2.3" },
new() { Id = 13, ParentId = 7, Name = "Top Level 2.3.1" },
new() { Id = 14, ParentId = 13, Name = "Top Level 2.3.1.1" },
new() { Id = 8, ParentId = 4, Name = "Top Level 2.4" },
new() { Id = 9, ParentId = 0, Name = "Top Level 3" },
};
private void TestTraversalMethod()
{
var hierarchyList = flatList.ToHierarchy(t => t.Id, t => t.ParentId);
var node = hierarchyList.FirstOrDefault(n => n.Data?.Id == 7); // Returns the node with Id 7
var siblingNodes = node.GetAllSiblingNodes(); // Returns the following nodes { 5, 6, 8 } (NOTE: This excludes the node being used)
var childNodes = node.GetAllChildrenNodes(); // Returns the following nodes { 13, 14 }
var parentNodes = node.GetAllParentNodes(); // Returns the following nodes { 4 }
var leafNodes = node.GetLeafNodes(); // Returns the following node { 14 }
var rootNode = node.GetRootNode(); // Returns
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.1 | 1,817 | 4/17/2022 |
1.1.0 | 402 | 4/16/2022 |
1.0.2 | 390 | 4/15/2022 |
1.0.1 | 400 | 4/15/2022 |
1.0.0-alpha | 137 | 4/14/2022 |
initial release