-
Notifications
You must be signed in to change notification settings - Fork 24
Libraries
Rohan Singh edited this page Feb 17, 2024
·
4 revisions
Libraries can be loaded into states by setting the Libraries
property on the state. For example, if we only want the print functions we could create our state like this:
var state = new MondState
{
Libraries = new MondLibraryManager
{
new ConsoleOutputLibrary()
}
};
Some libraries have properties that can be changed. The ConsoleOutput library has an option to change where output is sent. To access this we need to use a configuration function:
state.Libraries.Configure(libs =>
{
var consoleOutput = libs.Get<ConsoleOutputLibrary>();
consoleOutput.Out = new StreamWriter("output.txt")
{
AutoFlush = true
};
});
The libraries can now be used in scripts run in this state:
state.Run("printLn('hello world');");