Path: redb/redb.PropsEditor/Components/NestedObjectEditor.razor 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.PropsEditor/Components/NestedObjectEditor.razor ---- @using redb.PropsEditor.Services @using Microsoft.FluentUI.AspNetCore.Components @inject PropsMetadataService MetadataService @* Renders a nested object with expandable properties *@
@(isExpanded ? "▼" : "▶") @GetTypeName() @if (Value == null) { (null) @if (!IsReadOnly) { Create } }
@if (isExpanded && Value != null) {
@foreach (var prop in GetProperties()) { }
}
@code { /// /// The type of the nested object. /// [Parameter, EditorRequired] public required Type PropertyType { get; set; } /// /// The current value of the object. /// [Parameter] public object? Value { get; set; } /// /// Called when the value changes. /// [Parameter] public EventCallback OnValueChanged { get; set; } /// /// Whether the editor is read-only. /// [Parameter] public bool IsReadOnly { get; set; } private bool isExpanded = false; private string GetTypeName() { return PropertyType.Name; } private IEnumerable GetProperties() { return MetadataService.GetProperties(PropertyType); } private async Task NotifyChanged() { await OnValueChanged.InvokeAsync(Value); } private async Task CreateInstance() { try { Value = Activator.CreateInstance(PropertyType); isExpanded = true; await OnValueChanged.InvokeAsync(Value); } catch { // Cannot create instance } } }