当前位置: 首页>>代码示例>>C#>>正文


C# RouteDirection.Equals方法代码示例

本文整理汇总了C#中RouteDirection.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# RouteDirection.Equals方法的具体用法?C# RouteDirection.Equals怎么用?C# RouteDirection.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RouteDirection的用法示例。


在下文中一共展示了RouteDirection.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Match

        protected override bool Match(
			HttpContextBase httpContext,
			Route route,
			string parameterName,
			RouteValueDictionary values,
			RouteDirection routeDirection)
        {
            bool matches;
            if (routeDirection.Equals(RouteDirection.IncomingRequest))
            {
                var formMethod = httpContext.Request.Form["_method"];
                if (formMethod == null)
                {
                    matches = false;
                }
                else
                {
                    matches = base.Match(httpContext, route, parameterName, values, routeDirection);
                }
            }
            else
            {
                // Don't try to generate any URLs for this route; you need to use
                // a form value instead
                matches = false;
            }
            return matches;
        }
开发者ID:softcraft-development,项目名称:restful-routing,代码行数:28,代码来源:PostOverrideConstraint.cs

示例2: Match

        public static bool Match(IReadOnlyDictionary<string, IRouteConstraint> constraints,
                                 IDictionary<string, object> routeValues,
                                 HttpContext httpContext,
                                 IRouter route,
                                 RouteDirection routeDirection,
                                 ILogger logger)
        {
            if (routeValues == null)
            {
                throw new ArgumentNullException(nameof(routeValues));
            }

            if (httpContext == null)
            {
                throw new ArgumentNullException(nameof(httpContext));
            }

            if (route == null)
            {
                throw new ArgumentNullException(nameof(route));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (constraints == null)
            {
                return true;
            }

            foreach (var kvp in constraints)
            {
                var constraint = kvp.Value;
                if (!constraint.Match(httpContext, route, kvp.Key, routeValues, routeDirection))
                {
                    if (routeDirection.Equals(RouteDirection.IncomingRequest))
                    {
                        object routeValue;
                        routeValues.TryGetValue(kvp.Key, out routeValue);

                        logger.LogVerbose(
                            "Route value '{RouteValue}' with key '{RouteKey}' did not match " +
                            "the constraint '{RouteConstraint}'.",
                            routeValue,
                            kvp.Key,
                            kvp.Value);
                    }

                    return false;
                }
            }

            return true;
        }
开发者ID:qiudesong,项目名称:Routing,代码行数:56,代码来源:RouteConstraintMatcher.cs

示例3: Match

        public static bool Match(
            IDictionary<string, IRouteConstraint> constraints,
            RouteValueDictionary routeValues,
            HttpContext httpContext,
            IRouter route,
            RouteDirection routeDirection,
            ILogger logger)
        {
            if (routeValues == null)
            {
                throw new ArgumentNullException(nameof(routeValues));
            }

            if (httpContext == null)
            {
                throw new ArgumentNullException(nameof(httpContext));
            }

            if (route == null)
            {
                throw new ArgumentNullException(nameof(route));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (constraints == null)
            {
                return true;
            }

            foreach (var kvp in constraints)
            {
                var constraint = kvp.Value;
                if (!constraint.Match(httpContext, route, kvp.Key, routeValues, routeDirection))
                {
                    if (routeDirection.Equals(RouteDirection.IncomingRequest))
                    {
                        object routeValue;
                        routeValues.TryGetValue(kvp.Key, out routeValue);

                        logger.RouteValueDoesNotMatchConstraint(routeValue, kvp.Key, kvp.Value);
                    }

                    return false;
                }
            }

            return true;
        }
开发者ID:leloulight,项目名称:Routing,代码行数:52,代码来源:RouteConstraintMatcher.cs


注:本文中的RouteDirection.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。