Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Classes.clsLesson"/> class.
        /// < /summary>
        /// <param name="filepath">Path to a valid json lesson.</param>
        public clsLesson(string filepath)
        {
            clsLesson newLesson = null;

            using (FileStream f = new FileStream(filepath, FileMode.Open))
            {
                DataContractJsonSerializer ser =
                    new DataContractJsonSerializer(typeof(clsLesson));

                newLesson = (clsLesson)ser.ReadObject(f);
            }

            //Set readonly variables
            this.Name           = newLesson.Name;
            this.Tasks          = (List <clsTask>)newLesson.Tasks;
            this.Version        = newLesson.Version;
            this.AllowedModules = newLesson.AllowedModules;
            this.lessonpath     = Path.GetDirectoryName(filepath);
            this.ModuleMap      = loadAllowedModules();

            try {
                this.activeTask = this.Tasks[0];
            } catch (Exception) {
                //WARNING: No tasks in this lesson, sandbox mode is active!
            }
        }
Example #2
0
        /// <summary>
        /// The entry point of the program, where the program control starts and 
        /// ends.
        /// </summary>
        /// <param name="args">The command-line arguments.
        ///  -l [jsonfile]
        ///  -h help
        ///  -v version
        /// </param>
        public static void Main(string[] args)
        {
            if (args.Length == 0) {
            Console.Write (help ());
            return;
              }

              switch (args [0].ToString().Trim()) {
              case "-l":
            currentLesson = getLesson (args [1].ToString ());
            lessonLoop ();
            break;
              case "-h":
            Console.Write (help ());
            break;
              case "-v":
            Console.Write (version ());
            break;
              default:
            Console.WriteLine ("Command not recognized, see help documentation:\n");
            Console.Write(help ());
            break;
              }
        }