BlueSky.SyntaxEditorWindow.SplitBSkyFormatParams C# (CSharp) Метод

SplitBSkyFormatParams() приватный Метод

private SplitBSkyFormatParams ( string command, string &first, string &rest, string &usertitle ) : void
command string
first string
rest string
usertitle string
Результат void
        private void SplitBSkyFormatParams(string command, out string first, out string rest, out string usertitle)
        {
            string firstParam = string.Empty;//for object to be formatted
            string restParams = string.Empty;//for remaining params
            usertitle = string.Empty; //for title if passed in function call by the user.

            //find header/title
            int ttlidx = command.IndexOf("singleTableOutputHeader");
            int eqlidx = 0;
            int commaidx = 0;
            int closebracketidx = 0;
            int headerstartidx = 0;
            int headerendidx = 0;//modify this to right value
            if (ttlidx > 0) //if title is provided
            {
                eqlidx = command.IndexOf("=", ttlidx);
                if (eqlidx > ttlidx)
                {
                    headerstartidx = eqlidx + 1;
                    headerendidx = eqlidx + 1;//modify this to right value
                    commaidx = command.IndexOf(",", eqlidx);
                    closebracketidx = command.IndexOf(")", eqlidx);
                    //Now closing bracket will always be present but comma may or may not be. 
                    //Depending on if singleTableOutputHeader is last param or not.
                    if (commaidx > eqlidx) //comma is present
                    {
                        headerendidx = commaidx - 1;
                    }
                    else //comma not present so end marker is closing bracket
                    {
                        headerendidx = closebracketidx - 1;
                    }
                }
                usertitle = command.Substring(headerstartidx, (headerendidx - headerstartidx) + 1);
            }


            ///Logic Starts
            //look for first comma and split the parameters in two
            int paramstart = command.IndexOf("BSkyFormat(") + 11;//11 is the length of BSkyFormat(
            string allParams = command.Substring(paramstart, command.Length - 12); //ignore last ')'
            int indexOfComma = -1;
            int brackets = 0;
            for (int idx = 0; idx < allParams.Length; idx++)
            {
                if (allParams.ElementAt(idx) == '(')
                    brackets++;
                else if (allParams.ElementAt(idx) == ')')
                    brackets--;
                else if (brackets == 0 && allParams.ElementAt(idx) == ',')
                    indexOfComma = idx;
                else
                    continue;

                if (brackets == 0 && indexOfComma > 0)
                    break;
            }
            ///Logic Ends
            if (indexOfComma < 0) // comma not found, means no other params are in this func call.
            {
                first = allParams;
                rest = string.Empty;
            }
            else
            {
                first = allParams.Substring(0, indexOfComma);
                rest = allParams.Substring(indexOfComma + 1);
            }
        }
SyntaxEditorWindow