Keep cloned collection edits inside their owning driver dialog

This commit is contained in:
Joseph Doherty
2026-11-14 02:10:43 -05:00
parent 03ace0f9ee
commit cb26ed9179
35 changed files with 1749 additions and 74 deletions
@@ -0,0 +1,18 @@
using System.Reflection;
using CollectionCanary.Components;
using Microsoft.AspNetCore.DataProtection;
using ZB.MOM.WW.OtOpcUa.AdminUI.Uns;
var builder=WebApplication.CreateBuilder(args);builder.WebHost.UseStaticWebAssets();builder.Services.AddRazorComponents().AddInteractiveServerComponents();builder.Services.AddDataProtection().UseEphemeralDataProtectionProvider();builder.Services.AddScoped<FixtureState>();builder.Services.AddScoped<IRawTreeService>(sp=>{var proxy=DispatchProxy.Create<IRawTreeService,FixtureRaw>();((FixtureRaw)(object)proxy).State=sp.GetRequiredService<FixtureState>();return proxy;});
var app=builder.Build();app.UseAntiforgery();app.MapStaticAssets();app.MapRazorComponents<App>().AddInteractiveServerRenderMode();app.Run();
public sealed class FixtureState {public int Requests;public string Json="{\"endpointUrls\":[\"opc.tcp://fixture-a:4840\",\"opc.tcp://fixture-b:4840\"]}";}
public class FixtureRaw:DispatchProxy
{
public FixtureState State=null!;
protected override object? Invoke(MethodInfo? method,object?[]? args)=>method?.Name switch
{
"LoadDriverForEditAsync"=>Task.FromResult<RawDriverEditDto?>(new("fixture-driver","fixture-driver","OpcUaClient",State.Json,null,[1,2])),
"UpdateDriverAsync"=>Update(args!),
_=>throw new InvalidOperationException("Synthetic fixture refuses "+method?.Name)
};
private Task<UnsMutationResult> Update(object?[] args){if(args[0] is not string target || target!="fixture-driver")throw new InvalidOperationException("Unknown fixture target");State.Requests++;State.Json=(string)args[2]!;return Task.FromResult(new UnsMutationResult(true,null));}
}