Path: redb/redb.Core/Providers/ITreeProvider.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/Providers/ITreeProvider.cs ---- using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace redb.Core.Providers { /// /// Provider for tree structure operations. /// Permission checks managed centrally via configuration (similar to IObjectStorageProvider). /// public interface ITreeProvider { // ===== BASE METHODS (use _securityContext and configuration) ===== /// /// Load tree/subtree by root object ID (uses _securityContext and config.DefaultCheckPermissionsOnLoad). /// Loads root object and all its children recursively. /// Task> LoadTreeAsync(long rootObjectId, int? maxDepth = null, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Load tree/subtree (uses _securityContext and config.DefaultCheckPermissionsOnLoad). /// Task> LoadTreeAsync(IRedbObject rootObj, int? maxDepth = null, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Get direct children of object (uses _securityContext and config.DefaultCheckPermissionsOnLoad). /// Task>> GetChildrenAsync(IRedbObject parentObj, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Get path from object to root (uses _securityContext and config.DefaultCheckPermissionsOnLoad). /// Task>> GetPathToRootAsync(IRedbObject obj, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Get all object descendants (uses _securityContext and config.DefaultCheckPermissionsOnLoad). /// Task>> GetDescendantsAsync(IRedbObject parentObj, int? maxDepth = null, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Move object in tree (uses _securityContext and config.DefaultCheckPermissionsOnSave). /// Task MoveObjectAsync(IRedbObject obj, IRedbObject? newParentObj, CancellationToken cancellationToken = default); /// /// Create child object (uses _securityContext and config.DefaultCheckPermissionsOnSave). /// Task CreateChildAsync(TreeRedbObject obj, IRedbObject parentObj, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Delete object subtree recursively (uses _securityContext and config.DefaultCheckPermissionsOnDelete). /// Task DeleteSubtreeAsync(IRedbObject parentObj, CancellationToken cancellationToken = default); // ===== OVERLOADS WITH EXPLICIT USER (use configuration) ===== /// /// Load tree/subtree by root object ID with explicit user (uses config.DefaultCheckPermissionsOnLoad). /// Task> LoadTreeAsync(long rootObjectId, IRedbUser user, int? maxDepth = null, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Load tree/subtree with explicit user (uses config.DefaultCheckPermissionsOnLoad). /// Task> LoadTreeAsync(IRedbObject rootObj, IRedbUser user, int? maxDepth = null, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Get direct children of object with explicit user (uses config.DefaultCheckPermissionsOnLoad). /// Task>> GetChildrenAsync(IRedbObject parentObj, IRedbUser user, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Get path from object to root with explicit user (uses config.DefaultCheckPermissionsOnLoad). /// Task>> GetPathToRootAsync(IRedbObject obj, IRedbUser user, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Get all object descendants with explicit user (uses config.DefaultCheckPermissionsOnLoad). /// Task>> GetDescendantsAsync(IRedbObject parentObj, IRedbUser user, int? maxDepth = null, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Move object in tree with explicit user (uses config.DefaultCheckPermissionsOnSave). /// Task MoveObjectAsync(IRedbObject obj, IRedbObject? newParentObj, IRedbUser user, CancellationToken cancellationToken = default); /// /// Create child object with explicit user (uses config.DefaultCheckPermissionsOnSave). /// Task CreateChildAsync(TreeRedbObject obj, IRedbObject parentObj, IRedbUser user, CancellationToken cancellationToken = default) where TProps : class, new(); /// /// Delete object subtree recursively with explicit user (uses config.DefaultCheckPermissionsOnDelete). /// Task DeleteSubtreeAsync(IRedbObject parentObj, IRedbUser user, CancellationToken cancellationToken = default); // ===== POLYMORPHIC METHODS (for mixed trees) ===== /// /// Load polymorphic tree/subtree - supports objects of different schemes in one tree. /// Uses _securityContext and config.DefaultCheckPermissionsOnLoad. /// Task LoadPolymorphicTreeAsync(IRedbObject rootObj, int? maxDepth = null, CancellationToken cancellationToken = default); /// /// Get all direct children of object regardless of their schemes. /// Uses _securityContext and config.DefaultCheckPermissionsOnLoad. /// Task> GetPolymorphicChildrenAsync(IRedbObject parentObj, CancellationToken cancellationToken = default); /// /// Get polymorphic path from object to root - objects can be of different schemes. /// Uses _securityContext and config.DefaultCheckPermissionsOnLoad. /// Task> GetPolymorphicPathToRootAsync(IRedbObject obj, CancellationToken cancellationToken = default); /// /// Get all polymorphic descendants of object regardless of their schemes. /// Uses _securityContext and config.DefaultCheckPermissionsOnLoad. /// Task> GetPolymorphicDescendantsAsync(IRedbObject parentObj, int? maxDepth = null, CancellationToken cancellationToken = default); // ===== POLYMORPHIC METHODS WITH EXPLICIT USER ===== /// /// Load polymorphic tree/subtree with explicit user. /// Uses config.DefaultCheckPermissionsOnLoad. /// Task LoadPolymorphicTreeAsync(IRedbObject rootObj, IRedbUser user, int? maxDepth = null, CancellationToken cancellationToken = default); /// /// Get all direct children of object regardless of their schemes with explicit user. /// Uses config.DefaultCheckPermissionsOnLoad. /// Task> GetPolymorphicChildrenAsync(IRedbObject parentObj, IRedbUser user, CancellationToken cancellationToken = default); /// /// Get polymorphic path from object to root with explicit user. /// Uses config.DefaultCheckPermissionsOnLoad. /// Task> GetPolymorphicPathToRootAsync(IRedbObject obj, IRedbUser user, CancellationToken cancellationToken = default); /// /// Get all polymorphic descendants of object with explicit user. /// Uses config.DefaultCheckPermissionsOnLoad. /// Task> GetPolymorphicDescendantsAsync(IRedbObject parentObj, IRedbUser user, int? maxDepth = null, CancellationToken cancellationToken = default); // ===== POLYMORPHISM INITIALIZATION ===== /// /// Initialize AutomaticTypeRegistry for polymorphic operation support. /// Should be called at application startup. /// Task InitializeTypeRegistryAsync(CancellationToken cancellationToken = default); } }