Ejemplo n.º 1
0
    public void CreateNewCurrent()
    {
        GameObject current = Instantiate(currentPrefab, new Vector3(0, 0, 0), Quaternion.identity);

        CurrentScript    = current.GetComponent <CurrentScript>();
        lineRenderScript = current.GetComponent <CurrentTest>();
    }
Ejemplo n.º 2
0
        public bool IsCompletionTriggerCharacter(int position)
        {
            var currentScriptText   = CurrentScript.GetText();
            var completionProviders = _completionService.GetDefaultCompletionProviders();

            return(_completionService.IsTriggerCharacter(currentScriptText, position, completionProviders));
        }
Ejemplo n.º 3
0
        /// <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);
                        newInterface.PathFile = actLine.Arguments[Constants.KeywordInterface] + Parser.FileExtension;
                        Interfaces.Add(newInterface.Name, newInterface);
                    }
                    else if (actLine.ActionName == Constants.ActionStartScript)
                    {
                        Script newScript = new Script(Parser);
                        newScript.PathFile = 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();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// execute the script
        /// </summary>
        private void Run(IReporter reporter)
        {
            while (Scripts.Count > 0 && !IsStopped)
            {
                // pop a script from stack
                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 && !IsStopped)
                {
                    // get a action line from script
                    ActionLine actLineRaw = CurrentScript.Next();

                    if (actLineRaw.ActionName.Length == 0)
                    {
                        continue;
                    }

                    // manipulate action line with DataSet
                    ActionLine actLine = ManipulateData(actLineRaw);

                    // notify about action that is going to be performed
                    if (ActionPerforming != null)
                    {
                        string summary = actLine.ActionName;
                        if (actLine.WindowName != null)
                        {
                            summary += "\t[window:" + actLine.WindowName + "]";
                        }
                        if (actLine.ControlName != null)
                        {
                            summary += "\t[control:" + actLine.ControlName + "]";
                        }
                        foreach (string key in actLine.Arguments.Keys)
                        {
                            summary += "\t[" + key + ":" + actLine.Arguments[key] + "]";
                        }
                        ActionPerforming(summary);
                    }

                    // the action is 'use interface'
                    if (actLine.ActionName == Constants.Keywords.ActionUseInterface)
                    {
                        if (!Interfaces.ContainsKey(actLine.Arguments[Constants.Keywords.KeywordInterface].ToLower()))
                        {
                            IInterface newInterface = new Interface(Parser.NewInstance);
                            newInterface.FileName = actLine.Arguments[Constants.Keywords.KeywordInterface] + Parser.FileExtension;
                            Interfaces.Add(newInterface.Name, newInterface);
                        }
                    }
                    // the action is 'run script'
                    else if (actLine.ActionName == Constants.Keywords.ActionStartScript)
                    {
                        Script newScript = new Script(Parser.NewInstance);
                        newScript.FileName = actLine.Arguments[Constants.Keywords.KeywordScript] + Parser.FileExtension;

                        // push current script to stack and run new script
                        Scripts.Push(CurrentScript);
                        CurrentScript = newScript;

                        // begin new section in report
                        reporter.BeginScript(CurrentScript.Name);
                    }
                    else
                    {
                        try
                        {
                            IAction action = getAction(actLine);
                            if (action == null)
                            {
                                throw new Exception(Constants.Messages.Error_Executing_NoAction);
                            }

                            if (!action.IsValid())
                            {
                                throw new Exception(Constants.Messages.Error_Executing_InvalidArg);
                            }

                            // execute the action
                            int ret = action.Execute();

                            // write result of executing to report
                            reporter.WriteLine(actLine, action.Result);

                            // reset the action state
                            action.Reset();
                        }
                        catch (Exception e)
                        {
                            reporter.WriteError(actLine, e.Message);
                            InteruptWithError(e.Message);
                        }
                    }

                    // if the automation is paused, just sleep
                    CheckPaused();

                    // check if user interupt the automation
                    if (!CheckStopped())
                    {
                        ProcessSpeed();
                    }
                }

                // if the automation is paused, just sleep
                CheckPaused();

                // check if user interupt the automation
                CheckStopped();

                // end section in report
                if (CurrentScript.CurrentLineNumber > 0)
                {
                    reporter.EndScript(CurrentScript.Name);
                }
            }
        }
Ejemplo n.º 5
0
 protected override void OnPrint(string str)
 {
     CurrentScript.Print(str, LogLevel.Info);
 }
Ejemplo n.º 6
0
 public static void warn(params string[] text)
 {
     CurrentScript.Print(string.Join(" ", text), LogLevel.Warn);
 }