Esempio n. 1
0
 /// <summary>This is a driver for the example programs.</summary>
 /// <remarks>
 /// This is a driver for the example programs.
 /// It looks at the first command line argument and tries to find an
 /// example program with that name.
 /// If it is found, it calls the main method in that class with the rest
 /// of the command line arguments.
 /// </remarks>
 /// <param name="args">The argument from the user. args[0] is the command to run.</param>
 /// <returns>-1 on error, 0 on success</returns>
 /// <exception cref="System.MissingMethodException"></exception>
 /// <exception cref="System.Security.SecurityException"></exception>
 /// <exception cref="System.MemberAccessException"></exception>
 /// <exception cref="System.ArgumentException"></exception>
 /// <exception cref="System.Exception">Anything thrown by the example program's main</exception>
 public virtual int Run(string[] args)
 {
     // Make sure they gave us a program name.
     if (args.Length == 0)
     {
         System.Console.Out.WriteLine("An example program must be given as the" + " first argument."
                                      );
         PrintUsage(programs);
         return(-1);
     }
     // And that it is good.
     ProgramDriver.ProgramDescription pgm = programs[args[0]];
     if (pgm == null)
     {
         System.Console.Out.WriteLine("Unknown program '" + args[0] + "' chosen.");
         PrintUsage(programs);
         return(-1);
     }
     // Remove the leading argument and call main
     string[] new_args = new string[args.Length - 1];
     for (int i = 1; i < args.Length; ++i)
     {
         new_args[i - 1] = args[i];
     }
     pgm.Invoke(new_args);
     return(0);
 }
Esempio n. 2
0
 /// <summary>This is the method that adds the classed to the repository</summary>
 /// <param name="name">The name of the string you want the class instance to be called with
 ///     </param>
 /// <param name="mainClass">The class that you want to add to the repository</param>
 /// <param name="description">The description of the class</param>
 /// <exception cref="System.MissingMethodException"></exception>
 /// <exception cref="System.Security.SecurityException"></exception>
 /// <exception cref="System.Exception"/>
 public virtual void AddClass(string name, Type mainClass, string description)
 {
     programs[name] = new ProgramDriver.ProgramDescription(mainClass, description);
 }