private bool IsValid(MatchingCandidate matchingCandidate) { if (matchingCandidate.Validate()) { string value; if (_variables.TryGetValue(matchingCandidate.Key, out value)) { matchingCandidate.Value = value; return(true); } } return(false); }
public void CheckMatch(string str, int index) { var c = str[index]; DelimiterType typeOfDelimiter; if (_delimiter.IsDelimiter(c, out typeOfDelimiter)) { switch (typeOfDelimiter) { case DelimiterType.Start: var candidate = new MatchingCandidate(str, index); _openCandidates.Add(candidate); Candidates.Add(candidate); break; case DelimiterType.End: var matchingCandidate = _openCandidates.Last(); matchingCandidate.AppendDelimiterEnd(c); _openCandidates.Remove(matchingCandidate); break; case DelimiterType.StartContinue: _openCandidates.Last().AppendDelimiterStart(c); break; default: throw new ArgumentOutOfRangeException(); } } else { foreach (var candidate in _openCandidates) { candidate.Append(c); } } }