private static void WriteTitle(IInteractivity interactivity, Int32 index, ITutorialSnippet snippet) { var nr = index + 1; interactivity.Write("#" + nr + " " + snippet.Title); interactivity.Write(Environment.NewLine); interactivity.Write(Environment.NewLine); interactivity.Write(snippet.Description); interactivity.Write(Environment.NewLine); interactivity.Write(Environment.NewLine); }
private static void WriteExample(IInteractivity interactivity, Action <String> evaluate, ITutorialSnippet snippet) { interactivity.Write("Example:"); interactivity.Write(Environment.NewLine); interactivity.Write("SWM> "); interactivity.Write(snippet.ExampleCommand); interactivity.Write(Environment.NewLine); evaluate.Invoke(snippet.ExampleCommand); }
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); }
private static void WriteTask(IInteractivity interactivity, ITutorialSnippet snippet) { interactivity.Write("Your task: "); interactivity.Write(snippet.Task); interactivity.Write(Environment.NewLine); }
private static void WriteSolution(IInteractivity interactivity, Action <String> evaluate, ITutorialSnippet snippet) { interactivity.Write("Solution:"); interactivity.Write(Environment.NewLine); interactivity.Write("SWM> "); interactivity.Write(snippet.Solution); interactivity.Write(Environment.NewLine); evaluate.Invoke(snippet.Solution); interactivity.Write(Environment.NewLine); }