naquo

duval #1489671977734029 (suggested version)

Apr 1st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.10 KB | None | 0 0
  1. public class Command
  2.     {
  3.         /// <summary>The string by which this command will be called</summary>
  4.         public string commandKey;
  5.         /// <summary>The information of this command that the help option will show</summary>
  6.         public string helpInfo;
  7.  
  8.         public delegate String stringVoid();
  9.         public delegate String stringString(String consoleInput);
  10.         public delegate void voidCmd();
  11.         public delegate void voidString(String consoleInput);
  12.  
  13.         public delegate void cmd(String[] params, Console console);
  14.  
  15.         public cmd _cmd;
  16.  
  17.         public Command(String commandInput, String helpTooltip, cmd command)
  18.         {
  19.             commandKey = commandInput;
  20.             helpInfo = helpTooltip;
  21.             _cmd = command;
  22.         }
  23.  
  24.         #region CreateCommand Methods
  25.         public static Command createCommand(String commandInput, String helpTooltip, stringVoid command)
  26.         {
  27.             cmd wrappedCommand = (String[] params, Console console) => console.log(command());
  28.             return new Command(commandInput, helpTooltip, (String[] params, Console console) => console.log(command()));
  29.         }
  30.         public static Command createCommand(String commandInput, String helpTooltip, stringString command)
  31.         {
  32.             cmd wrappedCommand = (String[] params, Console console) => console.log(command(params.Length == 0 ? "" : params[0]));
  33.             return new Command(createCommand, helpTooltip, wrappedCommand);
  34.         }
  35.         public static Command createCommand(String commandInput, String helpTooltip, voidCmd command)
  36.         {
  37.             cmd wrappedCommand = (String[] params, Console console) => command();
  38.             return new Command(commandInput, helpTooltip, wrappedCommand);
  39.         }
  40.         public static Command createCommand(String commandInput, String helpTooltip, voidString command)
  41.         {
  42.             cmd wrappedCommand = (String[] params, Console console) => command(params.Length == 0 ? "" : params[0]);
  43.             return new Command(commandInput, helpTooltip, wrappedCommand);
  44.         }
  45.         #endregion
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment