Exemple #1
0
        /// <inheritdoc cref="IRouteConstraint.Match" />
        public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
        {
            switch (routeDirection)
            {
            case RouteDirection.IncomingRequest:
            {
                if (false == values.ContainsKey(routeKey))
                {
                    return(false);
                }

                var value = values[routeKey];

                return(NavigationCursorEncoder.TryParse(Convert.ToString(value), out var cursor) && null != cursor);
            }

            case RouteDirection.UrlGeneration:
            {
                if (false == values.ContainsKey(routeKey))
                {
                    return(false);
                }

                return(values[routeKey] is NavigationCursor);
            }
            }

            return(false);
        }
Exemple #2
0
        /// <inheritdoc cref="IOutboundParameterTransformer.TransformOutbound" />
        public string TransformOutbound(object value)
        {
            if (value is NavigationCursor cursor)
            {
                var token = NavigationCursorEncoder.ToEncodedString(cursor);
                return(token);
            }

            return(Convert.ToString(value));
        }