NewObject() 공개 메소드

public NewObject ( string name ) : object
name string
리턴 object
예제 #1
0
파일: TokenString.cs 프로젝트: bcr/sdf
        private static int ParseTokenString(TokenStringRegistry registry, int offset, string eval, TokenString returnString)
        {
            TokenString currentString = new TokenString();

            // Eat the TOKEN_START

            offset += TOKEN_START.Length;

            while (offset < eval.Length)
            {
                // Find the next TOKEN_START, comma, or TOKEN_END

                int tokenStartOffset = eval.IndexOf(TOKEN_START, offset);
                int commaOffset = eval.IndexOf(',', offset);
                int tokenEndOffset = eval.IndexOf(TOKEN_END, offset);

                if (tokenStartOffset > -1)
                {
                    commaOffset = (commaOffset == -1) ? eval.Length : commaOffset;
                    tokenEndOffset = (tokenEndOffset == -1) ? eval.Length : tokenEndOffset;
                }
                else if (commaOffset > -1)
                {
                    tokenEndOffset = (tokenEndOffset == -1) ? eval.Length : tokenEndOffset;
                }

                if ((tokenStartOffset > -1) && ((tokenStartOffset < commaOffset) && (tokenStartOffset < tokenEndOffset)))
                {
                    // If it's TOKEN_START, add this run to the current string, and call recursively

                    TokenString newString = new TokenString();

                    currentString.Add(eval.Substring(offset, tokenStartOffset - offset));

                    offset = ParseTokenString(registry, tokenStartOffset, eval, newString);
                    currentString.Add(newString);
                }
                else if ((commaOffset > -1) && (commaOffset < tokenEndOffset))
                {
                    // If it's a comma, add this run to the current string and start a new string

                    currentString.Add(eval.Substring(offset, commaOffset - offset));
                    returnString.AddArgument(currentString);
                    currentString = new TokenString();
                    offset = commaOffset + 1;
                }
                else
                {
                    // If it's a TOKEN_END, add this run to the current string and return

                    currentString.Add(eval.Substring(offset, tokenEndOffset - offset));
                    returnString.AddArgument(currentString);
                    returnString.Token = registry.NewObject(returnString.Name);
                    return tokenEndOffset + 1;
                }
            }

            return offset;
        }