GlueViewOfficialPlugins.Scripting.ScriptParsingPlugin.ApplyLinesInternal C# (CSharp) Method

ApplyLinesInternal() public method

public ApplyLinesInternal ( string lines, int startingIndex, int count, IElement element, CodeContext codeContext, string fileName = null, bool addStackVariables = true, bool removeStackVariables = true ) : bool
lines string
startingIndex int
count int
element IElement
codeContext GlueView.Scripting.CodeContext
fileName string
addStackVariables bool
removeStackVariables bool
return bool
        public bool ApplyLinesInternal(string[] lines, int startingIndex, int count, IElement element, 
            CodeContext codeContext, string fileName = null, bool addStackVariables = true, bool removeStackVariables = true)
        {
            LastErrorLine = -1;
            bool returnValue = true;
            mCallStackVariables.Add(new Dictionary<string, object>());
            for(int i = startingIndex; i < startingIndex + count && i < lines.Length; i++)
            {
                string line = lines[i];

                try
                {
                    int iBefore = i;
                    ApplyLine(line.Trim(), codeContext, lines, fileName, ref i);
                    if (iBefore != i)
                    {
                        // ApplyLine may increment the lines if in a 
                        // conditional code block.  If so we need to subtract
                        // 1 because our for-loop will automatically add one.
                        i--;
                    }


                }
                catch (StateSettingException e)
                {
                    string errorText = null;

                    if (string.IsNullOrEmpty(fileName))
                    {
                        errorText = "Error setting state for line:  ";
                    }
                    else
                    {
                        errorText = "Error setting state for line in the file " + fileName + ":  ";
                    }
                    AddErrorText(errorText + line);
                }
                catch (Exception)
                {
                    // There was a scripting error
                    // Eventually we want to log this
                    AddErrorText("Unknown line:  " + line);
                    returnValue = false;
                    LastErrorLine = i;
                    break;
                }
            }
            mCallStackVariables.Remove(TopOfVariableStack);
            return returnValue;
        }

Usage Example

Ejemplo n.º 1
0
        private void ReplTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                OutputTextBox.Text = "";
                string whatToProcess = ReplTextBox.Text;
                e.Handled          = true;
                e.SuppressKeyPress = true;
                mScriptParsingPlugin.ApplyLinesInternal(
                    new string[] { whatToProcess },
                    0,
                    1,
                    GlueViewState.Self.CurrentElement,
                    new CodeContext(GlueViewState.Self.CurrentElementRuntime));

                // We don't want to lose focus - that just
                // makes the output box gain focus.
                //ReplTextBox.Enabled = false;
                //ReplTextBox.Enabled = true;
                ReplTextBox.Text = "";
            }
        }