Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 private static void WriteTask(IInteractivity interactivity, ITutorialSnippet snippet)
 {
     interactivity.Write("Your task: ");
     interactivity.Write(snippet.Task);
     interactivity.Write(Environment.NewLine);
 }
Ejemplo n.º 5
0
 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);
 }