/// <summary> /// Executes the expression once. /// </summary> /// <param name="code">Code to execute</param> private void Execute(string code) { lastRunSuccesfull = true; code = code.Trim().Trim(';'); if (string.IsNullOrEmpty(code)) { return; } RexISM.Code = code; var compile = _compileEngine.GetCompileAsync(code, out Messages); if (compile != null) { if (_expressionHistory.Count == 0 || _expressionHistory[0].Code != code) { _expressionHistory.Insert(0, new RexHitoryItem { Code = code }); } var output = RexHelper.Execute <OutputEntry>(compile, out Messages); if (output != null) { RexHelper.AddOutput(output); } if (output == null || output.Exception != null) { lastRunSuccesfull = false; } } else { lastRunSuccesfull = false; } lastExecute = DateTime.Now; }
/// <summary> /// Displays a single variable, returns true if the varible was deleted else false. /// </summary> /// <param name="VarName">Name of the var. (key of the <see cref="RexHelper.Variables"/>)</param> /// <param name="var">The varible to display. (Value of the <see cref="RexHelper.Variables"/>)</param> private bool DisplayVariable(string VarName, RexHelper.Variable var) { string highlightedString; var type = RexUtils.GetCSharpRepresentation(var.VarType); // Format the code for syntax highlighting using richtext. highlightedString = RexUIUtils.SyntaxHighlingting(type.Concat(new[] { Syntax.Space, Syntax.Name(VarName), Syntax.Space, Syntax.EqualsOp, Syntax.Space }).Concat(RexReflectionUtils.GetSyntaxForValue(var.VarValue))); var shouldDelete = GUILayout.Button(_texts.GetText("remove_variable", tooltipFormat: VarName), GUILayout.Width(20)); // Draw the button as a label. if (GUILayout.Button(_texts.GetText("inspect_variable", highlightedString, VarName), varLabelStyle, GUILayout.ExpandWidth(true))) { var ouput = new OutputEntry(); ouput.LoadObject(var.VarValue); RexHelper.AddOutput(ouput); } return(shouldDelete); }