Skip to content

Template Exit

NebelFox edited this page Feb 20, 2022 · 1 revision

C# & Json

verbox.json

{
    "boxes": {
        "main": {
            "commands": [
                {
                    "name": "exit",
                    "brief": "terminates the application"
                }
            ]
        }
    }
}

Program.cs

var serializer = new Serializer();
serializer.Deserialize("verbox.json");
BoxBuilder builder = serializer.Boxes["main"];
builder.SetActionsByPaths(new Dictionary<string, Action<Context>>
{
    ["exit"] = context => context.Box.Terminate()
});
builder.Build()
       .StartDialogue();

Only C#

new BoxBuilder()
   .Command(new Command("exit", "terminates the application")
           .Action(context => context.Box.Terminate()))
   .Build()
   .StartDialogue();
Clone this wiki locally