public void setValue(T newValue, bool print = false)
        {
            T oldValue = this.value;

            this.value = newValue;
            if (print)
            {
                TerminalUtility.printCommandPass(this.text.format(this.value));
            }
            this.triggerChanged(oldValue, this.value);
        }
Пример #2
0
 public static void execute(string input, List <string> arguments = null, List <TerminalCommand> commands = null)
 {
     if (arguments == null)
     {
         if (string.IsNullOrEmpty(input))
         {
             return;
         }
         arguments = TerminalUtility.splitArguments(input);
     }
     if (commands == null && arguments.Count >= 1)
     {
         if (string.IsNullOrEmpty(input))
         {
             return;
         }
         commands = TerminalUtility.filterCommands(arguments[0]);
     }
     if (commands.Count == 1)
     {
         TerminalCommand terminalCommand = commands[0];
         if (arguments.Count == terminalCommand.parameters.Length + 1)
         {
             bool     flag  = true;
             object[] array = new object[terminalCommand.parameters.Length];
             for (int i = 0; i < array.Length; i++)
             {
                 array[i] = Terminal.parserRegistry.parse(terminalCommand.parameters[i].type, arguments[i + 1]);
                 if (array[i] == null)
                 {
                     TerminalUtility.printCommandFail(string.Concat(new string[]
                     {
                         "Unable to parse \"",
                         arguments[i + 1],
                         "\" as ",
                         terminalCommand.parameters[i].type.Name.ToString().ToLower(),
                         "!"
                     }));
                     flag = false;
                     break;
                 }
             }
             if (flag)
             {
                 terminalCommand.method.info.Invoke(null, array);
             }
         }
         else
         {
             TerminalUtility.printCommandFail(string.Concat(new object[]
             {
                 "Expected ",
                 terminalCommand.parameters.Length,
                 " argument(s), got ",
                 arguments.Count - 1,
                 "!"
             }));
         }
     }
     else
     {
         TerminalUtility.printCommandFail(string.Concat(new object[]
         {
             "Unable to determine intention of \"",
             input,
             "\" out of ",
             commands.Count,
             " commands!"
         }));
     }
 }
 public static void gc_collect()
 {
     GC.Collect();
     TerminalUtility.printCommandPass("Garbage collected!");
 }