Пример #1
0
 public NameMatch GetMatch(string line)
 {
     var result = _regex.Match(line);
     NameMatch match = null;
     if (result.Success)
     {
         if (result.Length == line.Length)
             match = new ExactMatch(GetParameters(result), line);
         else if (PartialMatchSupportedByMember())
             match = new PartialMatch(MemberInfo, GetParameters(result), result.Value,
                                     line.Substring(result.Length).Trim());
     }
     if (match != null)
     {
         DebugTrace.Trace("RegExp match",
                          "Member = " + MemberInfo.DeclaringType.Name + "." + MemberInfo.Name);
     }
     return match;
 }
        private IEnumerable<InvocationChain> GetChainsFromPartialMatch(PartialMatch partialMatch, string line)
        {
            var partialChain = new InvocationChain(BuildInvocation(partialMatch.MemberInfo, partialMatch));

            var matchedText = partialChain.Invocations.Last().MatchedText;
            var remainingLine = line.Substring(matchedText.Length).Trim();

            return TryToRecursivelyExtendPartialMatch(partialChain, remainingLine, partialMatch);
        }
        private IEnumerable<InvocationChain> TryToRecursivelyExtendPartialMatch(InvocationChain chain, string remainingLine,
            PartialMatch partial)
        {
            if (partial.TerminatingType == null)
                yield break;
            var chainedMapper = _factory.GetInterpreterForType(partial.TerminatingType);
            foreach (var childChain in chainedMapper.GetChains(remainingLine))
            {
                var union = chain.Invocations.Union(childChain.Invocations);

                yield return new InvocationChain(union.ToArray());
            }
        }
        private InvocationChain TryToRecursivelyExtendPartialMatch(InvocationChain chain, string remainingLine,
                                                                   PartialMatch partial)
        {
            var chainedMapper = _factory.GetInterpreterForType(partial.TerminatingType);
            var childChain = chainedMapper.GetChain(remainingLine);
            if (childChain == null)
                return null;

            var union = chain.Invocations.Union(childChain.Invocations);

            return new InvocationChain(union.ToArray());
        }