コード例 #1
0
ファイル: Script.cs プロジェクト: divyang4481/dotnetabt
        /// <summary>
        /// process script data from parser
        /// </summary>
        protected override void ProcessData()
        {
            base.ProcessData();

            foreach (SourceLine line in Parser.Lines)
            {
                if (line.ColumnCount > 0)
                {
                    ActionLine actLine = new ActionLine();
                    actLine.ActionName = line.Columns[0].ToLower();
                    for (int i = 1; i < line.ColumnCount; i++)
                    {
                        string[] pairs = line.Columns[i].Split(Constants.PropertyDelimeter.ToCharArray(), 2);
                        if (pairs.Length != 2)
                            throw new FormatException(Constants.Messages.Error_Parsing_Script);
                        if (Constants.KeywordWindow.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase))
                            actLine.WindowName = pairs[1].ToLower();
                        else if (Constants.KeywordControl.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase))
                            actLine.ControlName = pairs[1].ToLower();
                        else
                            actLine.Arguments[pairs[0].ToLower()] = pairs[1];
                    }
                    ActionLines.Add(actLine);
                }
            }
        }
コード例 #2
0
ファイル: Script.cs プロジェクト: yhtsnda/dotnetabt
        /// <summary>
        /// process script data from parser
        /// </summary>
        protected override void ProcessData()
        {
            base.ProcessData();

            foreach (SourceLine line in Parser.Lines)
            {
                if (line.ColumnCount > 0)
                {
                    ActionLine actLine = new ActionLine();
                    actLine.ActionName = line.Columns[0].ToLower();
                    for (int i = 1; i < line.ColumnCount; i++)
                    {
                        string[] pairs = line.Columns[i].Split(Constants.PropertyDelimeter.ToCharArray(), 2);
                        if (pairs.Length != 2)
                        {
                            throw new FormatException(Constants.Messages.Error_Parsing_Script);
                        }
                        if (Constants.KeywordWindow.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase))
                        {
                            actLine.WindowName = pairs[1].ToLower();
                        }
                        else if (Constants.KeywordControl.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase))
                        {
                            actLine.ControlName = pairs[1].ToLower();
                        }
                        else
                        {
                            actLine.Arguments[pairs[0].ToLower()] = pairs[1];
                        }
                    }
                    ActionLines.Add(actLine);
                }
            }
        }
コード例 #3
0
ファイル: Automation.cs プロジェクト: divyang4481/dotnetabt
        /// <summary>
        /// get corresponding Action object from all Action Managers
        /// </summary>
        /// <param name="actLine">the action line</param>
        /// <returns>the found action</returns>
        private Action getAction(ActionLine actLine)
        {
            int    i      = 0;
            Action action = null;

            while (action == null && i < ActionManagers.Count)
            {
                action = ActionManagers[i++].getAction(actLine);
            }

            return(action);
        }
コード例 #4
0
ファイル: ActionManager.cs プロジェクト: yhtsnda/dotnetabt
 /// <summary>
 /// create an action for the line
 /// </summary>
 /// <param name="actLine">the action line</param>
 /// <returns>the action</returns>
 public abstract Action getAction(ActionLine actLine);
コード例 #5
0
ファイル: Automation.cs プロジェクト: divyang4481/dotnetabt
        /// <summary>
        /// get corresponding Action object from all Action Managers
        /// </summary>
        /// <param name="actLine">the action line</param>
        /// <returns>the found action</returns>
        private Action getAction(ActionLine actLine)
        {
            int i = 0;
            Action action = null;
            while (action == null && i < ActionManagers.Count)
                action = ActionManagers[i++].getAction(actLine);

            return action;
        }
コード例 #6
0
 /// <summary>
 /// create an action for the line
 /// </summary>
 /// <param name="actLine">the action line</param>
 /// <returns>the action</returns>
 public abstract Action getAction(ActionLine actLine);
コード例 #7
0
ファイル: Automation.cs プロジェクト: divyang4481/dotnetabt
        /// <summary>
        /// execute the script
        /// </summary>
        private void Run()
        {
            IReporter reporter = Reporter.NewInstance;

            reporter.BeginReport("path");
            while (Scripts.Count > 0)
            {
                CurrentScript = Scripts.Pop();

                // begin new section in report
                if (CurrentScript.CurrentLineNumber == 0)
                {
                    reporter.BeginScript(CurrentScript.Name);
                }

                // loop for each line of current script
                while (CurrentScript.HasNextLine)
                {
                    ActionLine actLine = CurrentScript.Next();

                    if (actLine.ActionName == Constants.ActionUseInterface)
                    {
                        Interface newInterface = new Interface(Parser.NewInstance);
                        newInterface.FileName = actLine.Arguments[Constants.KeywordInterface] + Parser.FileExtension;
                        Interfaces.Add(newInterface.Name, newInterface);
                    }
                    else if (actLine.ActionName == Constants.ActionStartScript)
                    {
                        Script newScript = new Script(Parser.NewInstance);
                        newScript.FileName = actLine.Arguments[Constants.KeywordScript] + Parser.FileExtension;
                        Scripts.Push(CurrentScript);
                        CurrentScript = newScript;

                        // begin new section in report
                        reporter.BeginScript(CurrentScript.Name);
                    }
                    else
                    {
                        Action action = getAction(actLine);
                        if (action == null)
                        {
                            throw new InvalidOperationException("No action named '" + actLine.ActionName + "'");
                        }
                        if (!action.IsValid())
                        {
                            throw new InvalidOperationException("Invalid arguments for action named '" + actLine.ActionName + "'");
                        }

                        int ret = action.Execute();
                        action.Reset();

                        // write result of executing to report
                        reporter.WriteLine();
                    }
                }

                // end section in report
                if (CurrentScript.CurrentLineNumber > 0)
                {
                    reporter.EndScript();
                }
            }
        }