Exemplo n.º 1
0
        public void MatchValue()
        {
            var constraint = new RouteConstraintRegex("Test");
            var result = constraint.Match(null, null, "Param", new RouteValueDictionary { { "Param", "Test" }, { "OtherParam", "123" } }, RouteDirection.UrlGeneration);

            Assert.True(result);
        }
Exemplo n.º 2
0
        private void SetupConstraints(ILogger logger, IProxyFactory proxyFactory, System.Web.Routing.RouteValueDictionary constraints)
        {
            if (constraints != null)
            {
                var keys = constraints.Keys.ToList();
                for (var i = 0; i < keys.Count; i++)
                {
                    var constraintKey = keys[i];
                    var constraint    = constraints[constraintKey];

                    var originalObj = constraint as System.Web.Routing.IRouteConstraint;
                    var newObj      = (System.Web.Routing.IRouteConstraint)null;
                    if (originalObj == null)
                    {
                        var stringRouteConstraint = constraint as string;
                        if (stringRouteConstraint != null)
                        {
                            newObj = new RouteConstraintRegex(stringRouteConstraint);
                        }
                    }
                    else
                    {
                        routeConstraintAlternate.TryCreate(originalObj, out newObj);
                    }

                    if (newObj != null)
                    {
                        constraints[constraintKey] = newObj;
                        logger.Info(Resources.RouteSetupReplacedRoute, constraint.GetType());
                    }
                    else
                    {
                        logger.Info(Resources.RouteSetupNotReplacedRoute, constraint.GetType());
                    }
                }
            }
        }