private int RetrievePayloadIndex(string payload, IList <IParseTO> result, ref StringBuilder region, ref bool openRegion, ref IParseTO currentNode, ref IParseTO root, string methodPayload)
        {
            var previousPayload = '\0';
            int payloadIndex;

            for (payloadIndex = 0; payloadIndex < methodPayload.Length; payloadIndex++)
            {
                var currentPayload    = methodPayload[payloadIndex];
                var shouldAddToRegion = _parserHelper.ShouldAddToRegion(methodPayload, currentPayload, previousPayload, payloadIndex, true, '[');
                shouldAddToRegion = _parserHelper.ShouldAddToRegion(methodPayload, currentPayload, previousPayload, payloadIndex, shouldAddToRegion, ']');

                if (currentPayload == '[' && previousPayload == '[')
                {
                    currentNode    = openRegion ? _parserHelper.CurrentNode(currentNode, region, payloadIndex) : ParseTO(currentNode, payloadIndex, result, ref root, ref openRegion);
                    currentPayload = '\0';
                }

                if (currentPayload == ']' && previousPayload == ']')
                {
                    openRegion = _parserHelper.ProcessOpenRegion(payload, openRegion, payloadIndex, ref currentNode, ref region, ref currentPayload);
                }

                if (openRegion && shouldAddToRegion && currentPayload != '\0')
                {
                    region.Append(currentPayload);
                }
                previousPayload = currentPayload;
            }

            return(payloadIndex);
        }
Ejemplo n.º 2
0
 static bool ShouldAddToRegion(string payload, char cur, char prev, int i, bool shouldAddToRegion, char charToCheck) => _parserHelper.ShouldAddToRegion(payload, cur, prev, i, shouldAddToRegion, charToCheck);