GetAll() public static method

public static GetAll ( ) : uREPL.CommandInfo[]
return uREPL.CommandInfo[]
Beispiel #1
0
        protected override void OnEnable()
        {
            instance  = this;
            commands_ = Commands.GetAll();

            base.OnEnable();
        }
Beispiel #2
0
        static public bool ConvertIntoCodeIfCommand(ref string code)
        {
            // NOTE: If two or more commands that have a same name are registered,
            //       the first one will be used here. It is not correct but works well because
            //       evaluation will be done after expanding the command to the code.

            // To consider commands with spaces, check if the head of the given code is consistent
            // with any command name. command list is ranked in descending order of the command string length.
            var tmpCode     = code;
            var commandInfo = Commands.GetAll().FirstOrDefault(
                x => (tmpCode.Length >= x.command.Length) &&
                (tmpCode.Substring(0, x.command.Length) == x.command));

            // There is no command:
            if (commandInfo == null)
            {
                return(false);
            }

            // Remove last semicolon.
            code = code.TrimEnd(';');

            // Check command format
            if (commandInfo.HasArguments())
            {
                if (code.Substring(0, commandInfo.command.Length) != commandInfo.command)
                {
                    return(false);
                }
            }
            else
            {
                if (code.Length > commandInfo.command.Length)
                {
                    return(false);
                }
            }

            // Remove command and get only arguments.
            code = code.Substring(commandInfo.command.Length);

            // Store parentheses.
            var parentheses = CommandUtil.ConvertParenToPlaceholder(code);

            code = parentheses.output;

            // Store quatation blocks.
            var quates = CommandUtil.ConvertQuateToPlaceholder(code);

            code = quates.output;

            // Split arguments with space.
            var args = code.Split(new string[] { " " }, System.StringSplitOptions.RemoveEmptyEntries);

            // Convert the command into the Class.Method() style.
            code = commandInfo.GetFormat(args);

            // Replace temporary quates placeholders to actual expressions.
            code = CommandUtil.ConvertPlaceholderToBlock(code, quates);

            // Replace temporary parentheses placeholders to actual expressions.
            code = CommandUtil.ConvertPlaceholderToBlock(code, parentheses);

            return(true);
        }
Beispiel #3
0
        protected override void OnEnable()
        {
            commands_ = Commands.GetAll();

            base.OnEnable();
        }