/// <summary>Executes the command via CIL.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        public static bool TryIfCIL(CommandQueue queue, CommandEntry entry)
        {
            entry.SetData(queue, new IfCommandData()
            {
                Result = 0
            });
            bool success = TryIf(queue, entry, new List <Argument>(entry.Arguments));

            if (success)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "If is true, executing...");
                }
                ((IfCommandData)entry.GetData(queue)).Result = 1;
            }
            else
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "If is false, doing nothing!");
                }
            }
            return(success);
        }
Exemple #2
0
        /// <summary>Executes the command via CIL.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        public static bool TryIfCIL(CommandQueue queue, CommandEntry entry)
        {
            entry.SetData(queue, new IfCommandData()
            {
                Result = 0
            });
            if (entry.Arguments.Length == 0)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "Else is reached, executing block...");
                }
                ((IfCommandData)entry.GetData(queue)).Result = 1;
                return(true);
            }
            List <Argument> args = new(entry.Arguments);

            args.RemoveAt(0);
            bool success = IfCommand.TryIf(queue, entry, args);

            if (success)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "Else-If is true, executing...");
                }
                ((IfCommandData)entry.GetData(queue)).Result = 1;
            }
            else
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "Else-If is false, doing nothing!");
                }
            }
            return(success);
        }