本文整理汇总了C#中JintEngine.SetDebugMode方法的典型用法代码示例。如果您正苦于以下问题:C# JintEngine.SetDebugMode方法的具体用法?C# JintEngine.SetDebugMode怎么用?C# JintEngine.SetDebugMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JintEngine
的用法示例。
在下文中一共展示了JintEngine.SetDebugMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
string line;
var jint = new JintEngine();
jint.SetFunction("print", new Action<object>(s => { Console.ForegroundColor = ConsoleColor.Blue; Console.Write(s); Console.ResetColor(); }));
jint.SetFunction("import", new Action<string>(s => { Assembly.LoadWithPartialName(s); }));
jint.Step =
(sender, information) =>
{
// Console.WriteLine("Step: {0} => {1}", information.CurrentStatement.Source, information.CurrentStatement.Source.Code);
return true;
};
jint.SetDebugMode(true);
jint.DisableSecurity();
while (true) {
Console.Write("jint > ");
StringBuilder script = new StringBuilder();
while (String.Empty != (line = Console.ReadLine())) {
if (line.Trim() == "exit") {
return;
}
if (line.Trim() == "reset") {
jint = new JintEngine();
break;
}
if (line.Trim() == "help" || line.Trim() == "?") {
Console.WriteLine(@"Jint Shell");
Console.WriteLine(@"");
Console.WriteLine(@"exit - Quits the application");
Console.WriteLine(@"import(assembly) - assembly: String containing the partial name of a .NET assembly to load");
Console.WriteLine(@"reset - Initialize the current script");
Console.WriteLine(@"print(output) - Prints the specified output to the console");
Console.WriteLine(@"");
break;
}
script.AppendLine(line);
}
Console.SetError(new StringWriter(new StringBuilder()));
try
{
jint.Run(script.ToString());
}
catch (Exception e) {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e.Message);
Console.ResetColor();
}
Console.WriteLine();
}
}