- Notifications
You must be signed in to change notification settings - Fork 49
Yantra
Taritsyn edited this page Aug 3, 2026
·
26 revisions
JavaScriptEngineSwitcher.Yantra contains a YantraJsEngine adapter (wrapper for the YantraJS version 1.2.421).
You can specify a settings of JS engine during its registration:
engineSwitcher.EngineFactories.AddYantra(newYantraSettings{ConsoleCallback=(stringtype,object[]args)=>{TextWriterwriter=type=="error"?Console.Error:Console.Out;if(type!="log"){ConsoleColortypeColor;switch(type){case"warn":typeColor=ConsoleColor.Yellow;break;case"error":typeColor=ConsoleColor.Red;break;default:typeColor=ConsoleColor.White;break;}Console.ForegroundColor=typeColor;writer.Write("{0}: ",type);}Console.ForegroundColor=ConsoleColor.White;for(intargIndex=0;argIndex<args.Length;argIndex++){if(argIndex>0){writer.Write(" ");}writer.Write(args[argIndex]??"null");}writer.WriteLine();}});If you manually create an instance of JS engine, then you can pass settings via the constructor:
IJsEngineengine=newYantraJsEngine(newYantraSettings{ConsoleCallback=(stringtype,object[]args)=>{
…
}});Consider in detail properties of the YantraSettings class:
| Property name | Data type | Default value | Description |
|---|---|---|---|
ConsoleCallback | YantraJsConsoleCallback delegate | null | JS debugging console callback. |
Debugger | YantraJS.Debugger.JSDebugger | null | Instance of JS debugger (for example, the YantraJS.Core.Debugger.V8Debugger) |