Path: redb/redb.Core/Models/Contracts/ITreeRedbObject.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Models/Contracts/ITreeRedbObject.cs ---- using System; using System.Collections.Generic; namespace redb.Core.Models.Contracts { /// /// Interface for REDB tree objects with navigational properties /// Extends IRedbObject adding tree navigation capabilities in memory /// Supports polymorphic trees (objects of different schemes in one tree) /// public interface ITreeRedbObject : IRedbObject { /// /// Reference to parent object (filled when loading tree) /// null for root nodes /// ITreeRedbObject? Parent { get; set; } /// /// Collection of child objects (filled when loading tree) /// Empty collection for leaf nodes /// ICollection Children { get; set; } /// /// Checks if node is leaf (has no children) /// bool IsLeaf { get; } /// /// Gets node level in tree (0 for root) /// Requires loaded hierarchy up to root through Parent references /// int Level { get; } /// /// Gets path from root to current node as sequence of IDs /// /// Sequence of IDs from root to current node IEnumerable GetPathIds(); /// /// Gets breadcrumbs for navigation /// /// Separator between elements (default " > ") /// Whether to include IDs in parentheses (default false) /// String like "Root > Category > Subcategory" or "Root (1) > Category (5) > Subcategory (23)" string GetBreadcrumbs(string separator = " > ", bool includeIds = false); /// /// Checks if current node is descendant of specified node /// /// Alleged ancestor /// true if current node is descendant of ancestor bool IsDescendantOf(ITreeRedbObject ancestor); /// /// Checks if current node is ancestor of specified node /// /// Alleged descendant /// true if current node is ancestor of descendant bool IsAncestorOf(ITreeRedbObject descendant); /// /// Gets all subtree nodes (including current) in depth-first order /// /// Sequence of subtree nodes IEnumerable GetSubtree(); /// /// Gets number of nodes in subtree (including current) /// int SubtreeSize { get; } /// /// Gets maximum depth of subtree from current node /// int MaxDepth { get; } /// /// Gets all node ancestors (from parent to root) /// Requires loaded hierarchy up to root through Parent references /// IEnumerable Ancestors { get; } /// /// Gets all node descendants recursively /// Requires loaded hierarchy downwards through Children collections /// IEnumerable Descendants { get; } } /// /// Typed interface for tree objects with specific property type. /// Combines ITreeRedbObject (untyped navigation) and IRedbObject<TProps> (typed data). /// Supports polymorphic trees - parents and children can be different types. /// /// Object properties type. public interface ITreeRedbObject : ITreeRedbObject, IRedbObject where TProps : class, new() { // Empty interface - combines ITreeRedbObject + IRedbObject // Parent and Children inherited from ITreeRedbObject (untyped) // Props inherited from IRedbObject (typed) } }