private static object API_Eval_CS(string spec, object param) { var code = param?.ToString(); if (string.IsNullOrWhiteSpace(code)) { return(new ArgumentNullException(nameof(param))); } if (ScriptingLibrary.LoadLibraries() is Exception err) { return(err); } Info("API> {0}", code); var mod = (Api("api_stack mod") as string[])?.FirstOrDefault(e => e != "Zy.cSharp") ?? "API"; return(ScriptingEngine.Eval(mod, code)); }
private static void EvalToConsole(IConsole console, string code) { if (ScriptingLibrary.LoadLibraries() is Exception err) { console.Write(FormatException(err)); return; } var result = ScriptingEngine.Eval("Console", code); if (result == null && code.IndexOf('-') > 0) { return; // Ignore "null" result from assignment statement. } if (result is Exception ex) { result = FormatException(ex) + ex.StackTrace; } if (Api("console.write", result) is bool write && write) { return; }