Example #1
0
        public override DestinationPatternsMessageCondition Combine(DestinationPatternsMessageCondition other)
        {
            ISet <string> result = new HashSet <string>();

            if (Patterns.Count > 0 && other.Patterns.Count > 0)
            {
                foreach (var pattern1 in Patterns)
                {
                    foreach (var pattern2 in other.Patterns)
                    {
                        result.Add(_routeMatcher.Combine(pattern1, pattern2));
                    }
                }
            }
            else if (Patterns.Count > 0)
            {
                result = new HashSet <string>(Patterns);
            }
            else if (other.Patterns.Count > 0)
            {
                result = new HashSet <string>(other.Patterns);
            }
            else
            {
                result.Add(string.Empty);
            }

            return(new DestinationPatternsMessageCondition(result, _routeMatcher));
        }
Example #2
0
        private static ISet <string> PrependLeadingSlash(string[] patterns, IRouteMatcher routeMatcher)
        {
            var           slashSeparator = routeMatcher.Combine("a", "a").Equals("a/a");
            ISet <string> result         = new HashSet <string>();

            foreach (var pat in patterns)
            {
                var pattern = pat;
                if (slashSeparator && !string.IsNullOrEmpty(pattern) && !pattern.StartsWith("/"))
                {
                    pattern = "/" + pattern;
                }

                result.Add(pattern);
            }

            return(result);
        }