Class ResourceNode
Default IResource implementation: a concrete tree node backed by a thread-safe child collection. Subclass to override Count or DisposeWithParent, or to add metrics via IMetricSource.
public class ResourceNode : IResource, IDisposable
- Inheritance
-
ResourceNode
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
ResourceNode(string, ResourceType, IResource, ExhaustionPolicy, string)
Creates a node and registers it under parent, inheriting the parent's Owner.
public ResourceNode(string id, ResourceType type, IResource parent, ExhaustionPolicy exhaustionPolicy = ExhaustionPolicy.None, string name = null)
Parameters
idstringStable identifier, unique among
parent's children. Defaults to the runtime type name whennull.typeResourceTypeResource classification.
parentIResourceParent node; must be non-null (the root is created internally). This node is added to its children.
exhaustionPolicyExhaustionPolicyDiagnostic metadata describing how this node reacts when its capacity is exhausted. None for structural nodes.
namestringHuman-readable display label. Defaults to
idwhennull.
Properties
Children
Direct child resources, in no particular order.
public IEnumerable<IResource> Children { get; }
Property Value
Count
Default: no count. Subclasses that wrap a countable resource (ComponentTable, Segments folder, Index, …) override this to surface a live count to the Workbench tree.
public virtual int? Count { get; }
Property Value
- int?
CreatedAt
UTC timestamp captured when this node was constructed.
public DateTime CreatedAt { get; }
Property Value
DisposeWithParent
Whether this node is disposed by its parent's Dispose(bool) cascade. Default true. A node whose lifecycle is owned by something
other than the resource tree — e.g. a profiler exporter owned by TyphonProfiler — overrides this to false: it stays registered in the
tree for display, but is disposed only by its real owner, never by an ancestor's teardown.
public virtual bool DisposeWithParent { get; }
Property Value
ExhaustionPolicy
Diagnostic metadata indicating how this resource responds when its capacity limit is reached.
public ExhaustionPolicy ExhaustionPolicy { get; }
Property Value
Remarks
None for intermediate/structural nodes that don't own a bounded resource.
Id
Stable identifier, unique among siblings. Forms one segment of the node's tree path (e.g. "PageCache" in "Storage/PageCache").
public string Id { get; }
Property Value
Name
Human-readable display label. May equal Id for structural nodes whose id is already self-describing (e.g. "Storage"), but for resources with synthetic ids (GUIDs, hex suffixes) this is the user-facing name the Workbench and diagnostics should surface.
public string Name { get; }
Property Value
Owner
Registry that owns the tree this node belongs to.
public IResourceRegistry Owner { get; }
Property Value
Parent
Parent node in the tree, or null for the root.
public IResource Parent { get; }
Property Value
Type
Classification of this resource, used for filtering and display.
public ResourceType Type { get; }
Property Value
Methods
Dispose()
Disposes this node and, recursively, every child whose DisposeWithParent is true.
public void Dispose()
Dispose(bool)
Releases child resources. When disposing is true, cascades disposal to each child except those whose
DisposeWithParent is false (their lifecycle is owned elsewhere), then clears the child set.
protected virtual void Dispose(bool disposing)
Parameters
disposingbooltruewhen called from Dispose();falsefrom a finalizer, in which case this is a no-op.
RegisterChild(IResource)
Attaches child under this node and raises NodeMutated with
Added.
public bool RegisterChild(IResource child)
Parameters
childIResourceThe resource to attach.
Returns
RemoveChild(IResource)
Detaches resource from this node and raises NodeMutated with
Removed.
public bool RemoveChild(IResource resource)
Parameters
resourceIResourceThe child resource to detach.
Returns
- bool
trueif detached;falseif it was not a child of this node.