Summary
In this chapter, we explored formatters and magic commands in .NET Interactive and saw how they can be used to extend and enrich the notebook experience.
We discussed the built-in formatters and a few ways of customizing their behavior. We also saw how you can register a method to format objects differently using plain text, HTML, or JSON output.
Each magic command involves a directive, an optional set of parameters, and KernelCommand
, which is instantiated when the command is invoked.
Magic commands also have a command handler registered when the directive is added. These handlers can interact with various language kernels to display values, get or set variable values, or even execute code on different kernels.
While you won’t always need to customize formatters or build your own magic commands, these capabilities can be invaluable in designing a better notebook experience.
In the final chapter of this book, we’ll discuss where Polyglot Notebooks...