private void Evaluate(String content, Boolean showOutput) { try { var result = _interactivity.Run(_engine, content); if (showOutput) { var output = default(String); if (result != null) { output = Stringify.This(result); } _interactivity.Info(output); _engine.Scope["ans"] = result; } } catch (ParseException ex) { _interactivity.Display(ex.Error, content); } catch (Exception ex) { _interactivity.Error(ex.Message); } _interactivity.Write(Environment.NewLine); }
private void EvaluateCompleted(String input) { while (!input.IsCompleted()) { _interactivity.IsPromptShown = false; _interactivity.Info("... "); var rest = _interactivity.Read(); _interactivity.IsPromptShown = true; if (String.IsNullOrEmpty(rest)) { break; } input = String.Concat(input, Environment.NewLine, rest); } Evaluate(input, true); }
private static Boolean TryToLearn(IInteractivity interactivity, IDictionary <String, Object> scope, Action <String> evaluate, ITutorialSnippet snippet) { var hints = snippet.Hints.GetEnumerator(); var success = true; do { if (!success) { interactivity.Info(hints.Current); interactivity.Write(Environment.NewLine); } var input = interactivity.ReadLine(); evaluate.Invoke(input); success = snippet.Check(scope); }while (!success && hints.MoveNext()); return(success); }