@using LibMatrix.EventTypes.Spec.State.Policy @using System.Reflection @using ArcaneLibs.Attributes @using ArcaneLibs.Extensions @using LibMatrix @using System.Collections.Frozen @using LibMatrix.EventTypes @{ var policyData = (PolicyEvent.TypedContent as PolicyRuleEventContent)!; } @if (string.IsNullOrWhiteSpace(PolicyEvent.EventId)) { Policy type: } @{ // enumerate all properties with friendly name var props = PolicyEvent.MappedType.GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(x => (x.GetFriendlyNameOrNull() ?? x.GetJsonPropertyNameOrNull()) is not null) .Where(x => x.GetCustomAttribute() is null) .ToFrozenSet(); var propNames = props.Select(x => x.GetFriendlyNameOrNull() ?? x.GetJsonPropertyName()!).ToFrozenSet(); } @foreach (var prop in props) { @{ var getter = prop.GetGetMethod(); var setter = prop.GetSetMethod(); } @switch (Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType) { case Type t when t == typeof(string): {e}"); setter?.Invoke(policyData, [e]); StateHasChanged(); })"> break; default:

Unsupported type: @prop.PropertyType

break; } }
Property Value
@prop.GetFriendlyName() @if (Nullable.GetUnderlyingType(prop.PropertyType) is not null) { * }

        @PolicyEvent.ToJson(true, false)
    
Cancel Save @* Target entity: *@ @*
*@ @* Reason: *@ @* *@
@code { [Parameter] public StateEventResponse? PolicyEvent { get; set; } [Parameter] public required Action OnClose { get; set; } [Parameter] public required Action OnSave { get; set; } private static FrozenSet KnownPolicyTypes = StateEvent.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet(); private static Dictionary PolicyTypes = KnownPolicyTypes .ToDictionary(x => x.GetCustomAttributes().First(y => !string.IsNullOrWhiteSpace(y.EventName)).EventName, x => x); }