using Statum; using Invercargill; using Invercargill.DataStructures; namespace Example { // Typed slot models — GObject properties mapped to/from Properties via // GObjectMapping. ActionDto fields round-trip as nested JSON. public class CounterPrivate : Object { public int delta { get; set; } } public class CounterPublic : Object { public int value { get; set; } public Model.ActionDto bump { get; set; } } public class PagePublic : Object { public Model.ActionDto login { get; set; } } public class AuthPublic : Object { public string name { get; set; } public string role { get; set; } public Model.ActionDto logout { get; set; } } public class AuthPrivate : Object { public bool is_admin { get; set; } } /** * Entrypoint for the home page: hydrates counter + page slots with typed * models, embedding action references as fields. */ public class HomeEntrypoint : StatumEntrypoint { public override async DirectiveBuilder handle() throws GLib.Error { var bump_private = new CounterPrivate(); bump_private.delta = 1; var bump_ref = action_registry.author_private(bump_private); var counter = new CounterPublic(); counter.value = 0; counter.bump = bump_ref; var page = new PagePublic(); page.login = action_registry.author(); return directives() .set_typed("counter", Scope.PAGE, counter) .set_typed("page", Scope.PAGE, page); } } /** * Entrypoint for the guarded dashboard page. */ public class DashboardEntrypoint : StatumEntrypoint { public override async DirectiveBuilder handle() throws GLib.Error { return directives().notify("info", "Welcome to your dashboard"); } } }