Ejemplo n.º 1
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();
 }
Ejemplo n.º 2
0
    public void ExactMatch_Case_Sensitivity_Negate_Tests(bool ignoreCase, string inputString, bool negate, string pattern, bool expectedResult)
    {
        var context = new RewriteContext {
            HttpContext = new DefaultHttpContext()
        };
        var Match        = new ExactMatch(ignoreCase, inputString, negate);
        var matchResults = Match.Evaluate(pattern, context);

        Assert.Equal(expectedResult, matchResults.Success);
    }
Ejemplo n.º 3
0
 public bool Equals(FileSetting other)
 {
     return
         (Name.Equals(other.name) &&
          SheetIndex.Equals(other.SheetIndex) &&
          SheetName.Equals(other.SheetName) &&
          IsStartupSheet.Equals(other.IsStartupSheet) &&
          ColumnHeaderIndex.Equals(other.ColumnHeaderIndex) &&
          RowHeaderIndex.Equals(other.RowHeaderIndex) &&
          RowHeaderName.Equals(other.RowHeaderName) &&
          ExactMatch.Equals(other.ExactMatch) &&
          UseRegex.Equals(other.UseRegex) &&
          MaxRowHeaderWidth.Equals(other.MaxRowHeaderWidth));
 }
Ejemplo n.º 4
0
 public override int GetHashCode()
 {
     return(AttributionURL.GetHashCode()
            ^ Website.GetHashCode()
            ^ IsEEP.GetHashCode()
            ^ ExactMatch.GetHashCode()
            ^ Industry.GetHashCode()
            ^ NumberOfRatings.GetHashCode()
            ^ OverallRating.GetHashCode()
            ^ RatingDescription.GetHashCode()
            ^ CultureAndValuesRating.GetHashCode()
            ^ SeniorLeadershipRating.GetHashCode()
            ^ CompensationAndBenefitsRating.GetHashCode()
            ^ CareerOpportunitiesRating.GetHashCode()
            ^ WorkLifeBalanceRating.GetHashCode()
            ^ FeaturedReview.GetHashCode()
            ^ Ceo.GetHashCode());
 }
Ejemplo n.º 5
0
        public void AddConverter <TSrc, TDest, TAttribute>(
            Func <Type, Type, Func <object, object> > converterBuilder)
            where TAttribute : Attribute
        {
            var openTypeSource = GetOpenType <TSrc>();
            var openTypeDest   = GetOpenType <TDest>();

            if (openTypeSource == null)
            {
                openTypeSource = new ExactMatch(typeof(TSrc));
            }
            if (openTypeDest == null)
            {
                openTypeDest = new ExactMatch(typeof(TDest));
            }

            AddOpenConverter <TAttribute>(openTypeSource, openTypeDest, converterBuilder);
        }
Ejemplo n.º 6
0
            public override bool IsMatch(Type type, OpenTypeMatchContext context)
            {
                if (type == null)
                {
                    throw new ArgumentNullException(nameof(type));
                }
                if (context == null)
                {
                    throw new ArgumentNullException(nameof(context));
                }

                if (type.IsGenericType &&
                    ExactMatch.TypeEquals(type.GetGenericTypeDefinition(), _outerType))
                {
                    var args = type.GetGenericArguments();

                    return(_inner.IsMatch(args[0], context));
                }

                return(false);
            }
Ejemplo n.º 7
0
            public override bool IsMatch(Type type, OpenTypeMatchContext context)
            {
                if (type == null)
                {
                    throw new ArgumentNullException(nameof(type));
                }
                if (ExactMatch.TypeToString(type) == ExactMatch.TypeToString(_targetType))
                {
                    return(true);
                }

                // What if types are in different type universes?
                // Type is a concrete type.
                if (_targetType.IsInterface)
                {
                    var iface = type.GetInterface(_targetType.FullName);
                    return(iface != null);
                }

                // Fake types?
                return(false);
            }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        private static bool FindMatch(FileGroup[] fileGroups, RvFile file, Compare comp, ExactMatch match, out List <int> listIndex)
        {
            int intBottom = 0;
            int intTop    = fileGroups.Length;
            int intMid    = 0;
            int intRes    = -1;

            //Binary chop to find the closest match
            while ((intBottom < intTop) && (intRes != 0))
            {
                intMid = (intBottom + intTop) / 2;

                FileGroup ff = fileGroups[intMid];
                intRes = comp(file, ff);
                if (intRes < 0)
                {
                    intTop = intMid;
                }
                else if (intRes > 0)
                {
                    intBottom = intMid + 1;
                }
            }
            int index = intMid;

            listIndex = new List <int>();

            // if match was found check up the list for the first match
            if (intRes == 0)
            {
                int intRes1 = 0;
                while (index > 0 && intRes1 == 0)
                {
                    FileGroup ff = fileGroups[index - 1];
                    intRes1 = comp(file, ff);

                    if (intRes1 != 0)
                    {
                        continue;
                    }
                    index--;
                }

                int indexFirst = index;

                intTop  = fileGroups.Length;
                intRes1 = 0;
                while (index < intTop && intRes1 == 0)
                {
                    FileGroup ff = fileGroups[index];
                    intRes1 = comp(file, ff);
                    if (intRes1 != 0)
                    {
                        continue;
                    }
                    if (match(ff, file))
                    {
                        listIndex.Add(index);
                    }
                    index++;
                }

                if (listIndex.Count == 0)
                {
                    listIndex.Add(indexFirst);
                    intRes = -1;
                }
            }
            // if the search is greater than the closest match move one up the list
            else
            {
                if (intRes > 0)
                {
                    index++;
                }
                listIndex.Add(index);
            }

            return(intRes == 0);
        }
Ejemplo n.º 10
0
 // Use C# covariance?
 internal override string GetDisplayName()
 {
     return("+" + ExactMatch.TypeToString(_targetType));
 }