holmium
2
Probably something like this, assuming you won’t mind the DLR overhead on initial call:
EventHandlers["getMapDirectives"] += new Action<dynamic>(addCb =>
{
addCb('whatever', new Action<dynamic, dynamic>((state, arg) =>
{
state.add('whatever', arg);
Debug.WriteLine($"Adding {arg}");
}, new Action<dynamic>(state =>
{
Debug.WriteLine($"Destroying {state.whatever}.");
});
});
Which leads to a directive like
whatever 'arg'
For a 2-argument chain, simply return a closure like Lua does:
EventHandlers["getMapDirectives"] += new Action<dynamic>(addCb =>
{
addCb('whatever2', new Action<dynamic, dynamic>((state, arg) =>
{
return new Action<dynamic>(arg2 =>
{
state.add('whatever', arg);
state.add('whatever2', arg2.potato);
Debug.WriteLine($"Added {arg} {arg2.potato}.");
});
}, new Action<dynamic>(state =>
{
Debug.WriteLine($"Destroying {state.whatever}/{state.whatever2}.");
});
});
Usage:
whatever2 'meh' { potato = 42 }
Yes.