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); }
static bool ProcessOpenRegion(string payload, bool openRegion, int i, ref IParseTO currentNode, ref StringBuilder region, ref char cur) => _parserHelper.ProcessOpenRegion(payload, openRegion, i, ref currentNode, ref region, ref cur);