Пример #1
0
 public static void LoadAssembly(string assembly)
 {
     InteractiveBase.LoadAssembly(assembly);
 }
Пример #2
0
        public string ProcessCommand(string command)
        {
            string result   = "";
            string dataText = "";

            command = command.Remove(0, 1);

            int indexOfOpenAngleBracket = 0;
            int indexOfOpenParentheses  = 0;

            if (!command.EndsWith("();"))
            {
                if (command.Contains("<"))
                {
                    command = command.Replace(">();", "");
                    command = command.Replace("> ();", "");
                    indexOfOpenAngleBracket = command.IndexOf('<');
                    dataText = command.Substring(indexOfOpenAngleBracket + 1);
                }

                if (command.Contains("("))
                {
                    command = command.Replace(");", "");
                    indexOfOpenParentheses = command.IndexOf('(');
                    dataText = command.Substring(indexOfOpenParentheses + 1);
                }
            }
            else
            {
                command = command.Replace("();", "");
            }

            if (RuntimeUnityEditorCore._enableDebug)
            {
                File.WriteAllText(DebugHelpers.debugPath + "TELNET_CommandProcessDebug.txt", "command: " + command + "\r\ndata: " + dataText);
            }

            switch (command)
            {
            case "help":
                result = REPL.REPL.help;
                break;

            case "Describe":
                result = InteractiveBase.Describe((object)dataText);
                break;

            case "Print":
                if (!dataText.Contains(","))
                {
                    InteractiveBase.print((object)dataText);
                }
                else
                {
                    object[] dataParams = InitializeArray <object>(20);
                    InteractiveBase.print(dataText, dataParams);
                }
                break;

            case "LoadAssembly":
                InteractiveBase.LoadAssembly(dataText);
                break;

            case "LoadPackage":
                InteractiveBase.LoadPackage(dataText);
                break;

            case "ShowUsing":
                InteractiveBase.ShowUsing();
                break;

            case "ShowVars":
                InteractiveBase.ShowVars();
                break;

            case "Time":
                //TimeSpan resTime = InteractiveBase.Time(dataText);
                //result = resTime.ToString();
                break;

            // TESTING ---------------------------------------------------------------------------------------------------------------------------------------
            case "find<":
                try
                {
                    Object obj = UnityEngine.Object.FindObjectOfType(Type.GetType("\"" + dataText + "\""));
                    File.WriteAllText(DebugHelpers.debugPath + "TELNET_CommandProcessDebug.txt", "command: " + command + "\r\ndata: " + dataText);
                    if (obj != null)
                    {
                        File.WriteAllText(DebugHelpers.debugPath + "TMP.txt", "object is not null");
                    }

                    result = obj.QuickDump();
                }
                catch (Exception e)
                {
                    result = e.Message;
                }

                break;

            // END TESTING ------------------------------------------------------------------------------------------------------------------------------------
            default:
                break;
            }

            return(result);
        }