private string GetRoutePatternPartPropertyValue(RoutePatternPart part, out bool isOptional)
        {
            var value = string.Empty;

            if (part is RoutePatternLiteralPart literalPart)
            {
                value = literalPart.Content;
            }
            else if (part is RoutePatternParameterPart parameterPart)
            {
                value = parameterPart.Name;
            }

            bool.TryParse(part.GetType().GetProperty("IsOptional")?.GetValue(part).ToString(), out isOptional);

            return(value);
        }
Beispiel #2
0
        private bool Equals(RoutePatternPart x, RoutePatternPart y)
        {
            if (x.GetType() != y.GetType())
            {
                return(false);
            }

            if (x.IsLiteral && y.IsLiteral)
            {
                return(Equals((RoutePatternLiteralPart)x, (RoutePatternLiteralPart)y));
            }
            else if (x.IsParameter && y.IsParameter)
            {
                return(Equals((RoutePatternParameterPart)x, (RoutePatternParameterPart)y));
            }
            else if (x.IsSeparator && y.IsSeparator)
            {
                return(Equals((RoutePatternSeparatorPart)x, (RoutePatternSeparatorPart)y));
            }

            Debug.Fail("This should not be reachable. Do you need to update the comparison logic?");
            return(false);
        }