Пример #1
0
        public bool CompareShouldBeAffectedIgnoreCase(string left, string right, bool ignoreCase)
        {
            var expression = Expression.Constant("");
            var result     = new PartialMatch <CustomEntity>(":", ignoreCase).Compare(expression, OperandBuilder.BuildUp(left), OperandBuilder.BuildUp(right));

            return((bool)Expression.Lambda(result.Expression).Compile().DynamicInvoke());
        }
Пример #2
0
 public void SetupContext()
 {
     Matcher      = MethodMatcherTestHelper.GetMethodNameMatcher <MultiWordTestContext>("Foo");
     FoundMatches = Matcher.GetMatches("Foo Bar Baz");
     Partial      = FoundMatches.OfType <PartialMatch>().FirstOrDefault();
     Exact        = FoundMatches.OfType <ExactMatch>().FirstOrDefault();
 }
Пример #3
0
 private static int ByteIndexOf(byte[] arrayToSearch, byte[] patternToFind)
 {
     if (((patternToFind.Length != 0) && (arrayToSearch.Length != 0)) && (arrayToSearch.Length >= patternToFind.Length))
     {
         List <PartialMatch> list = new List <PartialMatch>();
         for (int i = 0; i < arrayToSearch.Length; i++)
         {
             for (int j = list.Count - 1; j >= 0; j--)
             {
                 if (arrayToSearch[i] == patternToFind[list[j].MatchLength])
                 {
                     PartialMatch local1 = list[j];
                     local1.MatchLength++;
                     if (list[j].MatchLength == patternToFind.Length)
                     {
                         return(list[j].Index);
                     }
                 }
                 else
                 {
                     list.Remove(list[j]);
                 }
             }
             if (arrayToSearch[i] == patternToFind[0])
             {
                 if (patternToFind.Length == 1)
                 {
                     return(i);
                 }
                 list.Add(new PartialMatch(i));
             }
         }
     }
     return(-1);
 }
Пример #4
0
        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));
        }
Пример #5
0
        public void GenericTypeTest()
        {
            var patt = typeof(ISqlSelect <RewriteTypes.C1>);
            var expr = typeof(Fluent.ISqlGroupByAble <Cliente, Factura, object>);

            var ret = PartialMatch.FromType(patt, expr);

            Assert.AreEqual(1, ret.Types.Count);
            Assert.AreEqual(typeof(Factura), ret.Types[typeof(RewriteTypes.C1)]);
        }
Пример #6
0
        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()));
            }
        }
Пример #7
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);
        }
Пример #8
0
 public bool CompareShouldBeAffectedIgnoreCase(string left, string right, bool ignoreCase)
 {
     var expression = Expression.Constant("");
     var result = new PartialMatch<CustomEntity>(":", ignoreCase).Compare(expression, OperandBuilder.BuildUp(left), OperandBuilder.BuildUp(right));
     return (bool)Expression.Lambda(result.Expression).Compile().DynamicInvoke();
 }
Пример #9
0
 public void SetUp()
 {
     testee = new PartialMatch<CustomEntity>(":");
 }
Пример #10
0
 public void SetUp()
 {
     testee = new PartialMatch <CustomEntity>(":");
 }