public void ConstInstructionFileNameParseTest()
        {
            ConstInstruction item = AConstInstruction.ConstInstructionFileNameParse("test(param1,param2)", false);

            Assert.AreEqual("test", item.constInstructionName);

            Assert.AreEqual(2, item.parameterList.Count);
            Assert.AreEqual("param1", item.parameterList[0]);
            Assert.AreEqual("param2", item.parameterList[1]);
        }
Example #2
0
        /// <summary>
        /// 执行指令,启动失败的启动项在ReportInfo中查看
        /// </summary>
        /// <exception cref="ConstInstructionParameterParseException"></exception>
        public override string Execute()
        {
            ReportInfo.Clear();
            AHelper.InstructionHistory.Insert(0, Instruction);

            ConstInstruction ci = new ConstInstruction();

            if (AConstInstruction.GetConstInstructionFrame(Instruction, ref ci))
            {
                bool allRight = true;
                try
                {
                    foreach (string instructionLine in ci.instructionLines)
                    {
                        // Instruction here firstly need to be parse (const quote / parameter parse).
                        // Const quote parse.
                        string instructionLine_cqp = AConstQuote.ConstQuoteParse(instructionLine);
                        // Parameter parse
                        ConstInstruction instructionAttribute   = AConstInstruction.ConstInstructionFileNameParse(Instruction, false);
                        string           instructionLine_cpq_pp = AConstInstruction.ConstInstructionParameterParse(ci, instructionLine_cqp, instructionAttribute.parameterList);
                        // Execute
                        AInstruction.GetInstruction(instructionLine_cpq_pp).Execute();
                        if (reportType != ReportType.OK)
                        {
                            allRight = false;
                        }
                    }
                }
                catch (Exception exception) { throw exception; }
                finally { if (!allRight)
                          {
                              reportType = ReportType.WARNING;
                          }
                }
                return(AInstruction.MSG_EXECUTE_SUCCESSFULLY);
            }
            else
            {
                reportType = ReportType.ERROR;
                throw new ConstInstructionNotFoundException(Instruction);
            }
        }