GraphView.GraphViewParser.ParseNestedObject C# (CSharp) Method

ParseNestedObject() private static method

private static ParseNestedObject ( List tokenList, int &nextToken, NestedObject &result, int &fareastError, bool supportMoreFieldType = false ) : bool
tokenList List
nextToken int
result NestedObject
fareastError int
supportMoreFieldType bool
return bool
        private static bool ParseNestedObject(
            List<AnnotationToken> tokenList,
            ref int nextToken,
            ref NestedObject result,
            ref int fareastError,
            bool supportMoreFieldType = false)
        {
            int currentToken = nextToken;
            string tokenStr = null;

            if (ReadToken(tokenList, AnnotationTokenType.LeftBrace, ref currentToken, ref tokenStr, ref fareastError))
            {
                string fieldName = null;
                NestedObject fieldValue = null;

                CollectionObject collectionObj = new CollectionObject()
                {
                    Collection = new Dictionary<string, NestedObject>()
                };
                // Field Name can be a NameToken or a DoubleQuotedString
                if ((ReadToken(tokenList, AnnotationTokenType.DoubleQuotedString, ref currentToken, ref fieldName, ref fareastError) ||
                    ReadToken(tokenList, AnnotationTokenType.NameToken, ref currentToken, ref fieldName, ref fareastError)) &&
                    ReadToken(tokenList, AnnotationTokenType.Colon, ref currentToken, ref tokenStr, ref fareastError) &&
                    ParseNestedObject(tokenList, ref currentToken, ref fieldValue, ref fareastError, supportMoreFieldType))
                {
                    collectionObj.Collection[fieldName.ToLower()] = fieldValue;
                }
                else
                {
                    return false;
                }

                while (ReadToken(tokenList, AnnotationTokenType.Comma, ref currentToken, ref tokenStr, ref fareastError) &&
                    (ReadToken(tokenList, AnnotationTokenType.DoubleQuotedString, ref currentToken, ref fieldName, ref fareastError) ||
                    ReadToken(tokenList, AnnotationTokenType.NameToken, ref currentToken, ref fieldName, ref fareastError)) &&
                    ReadToken(tokenList, AnnotationTokenType.Colon, ref currentToken, ref tokenStr, ref fareastError) &&
                    ParseNestedObject(tokenList, ref currentToken, ref fieldValue, ref fareastError, supportMoreFieldType))
                {
                    collectionObj.Collection[fieldName.ToLower()] = fieldValue;
                }

                if (!ReadToken(tokenList, AnnotationTokenType.RightBrace, ref currentToken, ref tokenStr, ref fareastError))
                {
                    return false;
                }

                result = collectionObj;
                nextToken = currentToken;
                return true;
            }
            else if (
                ReadToken(tokenList, AnnotationTokenType.DoubleQuotedString, ref currentToken, ref tokenStr,
                    ref fareastError)
                )
            {
                StringObject stringObj = new StringObject()
                {
                    Value = tokenStr
                };

                result = stringObj;
                nextToken = currentToken;
                return true;
            }
            else if (supportMoreFieldType &&
                 (ReadToken(tokenList, AnnotationTokenType.Integer, ref currentToken, ref tokenStr,
                     ref fareastError) ||
                  ReadToken(tokenList, AnnotationTokenType.Double, ref currentToken, ref tokenStr,
                      ref fareastError) ||
                  ReadToken(tokenList, AnnotationTokenType.Binary, ref currentToken, ref tokenStr,
                      ref fareastError) ||
                  ReadToken(tokenList, AnnotationTokenType.SingleQuotedString, ref currentToken, ref tokenStr,
                      ref fareastError)))
            {
                NormalObject normalObject = new NormalObject
                {
                    Value = tokenStr
                };
                result = normalObject;
                nextToken = currentToken;
                return true;
            }
            else
            {
                return false;
            }
        }