public static void InvokeAutoExec() { var console = QFSW.QC.QuantumConsole.Instance ? QFSW.QC.QuantumConsole.Instance : Object.FindObjectOfType <QFSW.QC.QuantumConsole>(); if (!console) { return; } InvokeMethod(console, "Initialize"); QuantumConsoleProcessor.GenerateCommandTable(); // Ensures the command table is generated try { InvokeConfigStreamingAssets(AUTOEXEC_NAME); } catch (FileNotFoundException) { // Ignore } catch (DirectoryNotFoundException) { // Ignore } try { InvokeConfig(Path.Combine(Directory.GetParent(Application.dataPath).ToString(), AUTOEXEC_NAME)); } catch (FileNotFoundException) { // Ignore } catch (DirectoryNotFoundException) { // Ignore } try { var customExecPath = CommandLineArguments.ReadArgValue("-ExecConfig"); customExecPath = customExecPath.Replace("{StreamingAssets}", Application.streamingAssetsPath); customExecPath = customExecPath.Replace("{DataPath}", Application.dataPath); customExecPath = customExecPath.Replace("{Root}", Directory.GetParent(Application.dataPath).ToString()); InvokeConfig(customExecPath); } catch (CommandLineArguments.CommandLineArgumentNotFoundException) { // Ignore } catch (Exception ex) { Debug.LogError(ex.ToString()); } try { foreach (var command in CommandLineArguments.ReadArgValues("-Exec")) { try { QuantumConsoleProcessor.InvokeCommand(command.Trim('"')); } catch (Exception ex) { Debug.LogError(ex.ToString()); } } } catch (CommandLineArguments.CommandLineArgumentNotFoundException) { // Ignore } catch (Exception ex) { Debug.LogError(ex.ToString()); } }
private void StartCoroutineCommand(string coroutineCommand) { object coroutineReturn = QuantumConsoleProcessor.InvokeCommand(coroutineCommand); if (coroutineReturn is IEnumerator) { StartCoroutine(coroutineReturn as IEnumerator); } else { throw new ArgumentException($"{coroutineCommand} is not a coroutine"); } }
private void Update() { if (!_blocked) { foreach (Binding binding in _bindings) { if (Input.GetKeyDown(binding.Key)) { try { QuantumConsoleProcessor.InvokeCommand(binding.Command); } catch (System.Exception e) { Debug.LogException(e); } } } } }
public object Parse(string value, Type type, Func <string, Type, object> recursiveParser) { bool nullable = false; if (value.EndsWith("?")) { nullable = true; value = value.Substring(0, value.Length - 1); } value = value.ReduceScope('{', '}'); object result = QuantumConsoleProcessor.InvokeCommand(value); if (result is null) { if (nullable) { if (type.IsClass) { return(result); } else { throw new ParserInputException($"Expression body {{{value}}} evaluated to null which is incompatible with the expected type '{type.GetDisplayName()}'."); } } else { throw new ParserInputException($"Expression body {{{value}}} evaluated to null. If this is intended, please use nullable expression bodies, {{expr}}?"); } } else if (result.GetType().IsCastableTo(type, true)) { return(type.Cast(result)); } else { throw new ParserInputException($"Expression body {{{value}}} evaluated to an object of type '{result.GetType().GetDisplayName()}', " + $"which is incompatible with the expected type '{type.GetDisplayName()}'."); } }