20 lines
1.3 KiB
C#
20 lines
1.3 KiB
C#
using System.Reflection;
|
|
using SimpleModalCanary.Components;
|
|
using ZB.MOM.WW.OtOpcUa.AdminUI.Uns;
|
|
var builder=WebApplication.CreateBuilder(args);builder.WebHost.UseStaticWebAssets();
|
|
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
|
|
builder.Services.AddSingleton<FixtureState>();
|
|
builder.Services.AddSingleton<IUnsTreeService>(services=> {var proxy=DispatchProxy.Create<IUnsTreeService,SyntheticUnsProxy>();((SyntheticUnsProxy)(object)proxy).State=services.GetRequiredService<FixtureState>();return proxy;});
|
|
var app=builder.Build();app.UseAntiforgery();app.MapStaticAssets();
|
|
app.MapGet("/fixture/provenance",()=>new {purpose="Loopback synthetic simple modal fixture",backend="No DB, driver, gateway or operational service registration"});
|
|
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();app.Run();
|
|
public sealed class FixtureState { public int Operations; }
|
|
public class SyntheticUnsProxy:DispatchProxy {
|
|
public FixtureState State {get;set;}=null!;
|
|
protected override object? Invoke(MethodInfo? method,object?[]? args) {
|
|
if(method?.Name is not ("CreateAreaAsync" or "CreateLineAsync"))throw new InvalidOperationException("Operation refused: "+method?.Name);
|
|
State.Operations++;return Complete();
|
|
}
|
|
private static async Task<UnsMutationResult> Complete(){await Task.Delay(600);return new(true,null);}
|
|
}
|