Utils.Get |
Sorts the tree by parents in order to be able to insert it by parents first
Namespace: Gamanet.C4.SimpleInterfaces
Assembly: Gamanet.C4.SimpleInterfaces (in Gamanet.C4.SimpleInterfaces.dll) Version: 2026.0.0.242
Syntax
C#
public static IList<T> GetSubtree<T>( TreeNode<T> treeRoot, Guid subtreeRootId ) where T : ISimpleEntity
Parameters
- treeRoot TreeNode<T>
- The tree root.
- subtreeRootId Guid
- The subtree root identifier.
Type Parameters
- T
- simple entity
Return Value
IList<T>Sorted subtree list by parents. In case that subtree root not exist it return empty collection
Example
The following example illustrates how Utils converts entities list to entities subtree.
C#
using System; using Gamanet.C4.SDK; using Gamanet.C4.SimpleInterfaces; public class UtilsGetSubtreeByRootId { static void Main() { // create instance of simple client var client = new SimpleClient(ConnectorConfiguration.RestClient, null); string token; // connect to file connector var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support123", out token); if (connectionResult != ConnectionResult.Successful) { Console.WriteLine("Connection unSuccessful, result: {0}", connectionResult); return; } Console.WriteLine("Connection result: {0}", connectionResult); Console.WriteLine(); // load all persons var persons = client.Persons.GetAll(); // create tree node structure, you can use it with hierarchical entities (SimplePerson, SimpleDevice, SimpleRegion) var treeNodeRoot = Utils.ListToTree(persons); // get subtree for Role root var personsTree = Utils.GetSubtree(treeNode, EntityRoot.Role); // display persons tree foreach (var person in personsTree) { Console.WriteLine(person.Name); } // disconnect from server client.Disconnect(); // The example displays the following output: // Connection result: Successful // RolesRoot // Manager // Reception // Administrator // Support // Dispatcher // Service Technician } }
See Also