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


C# RouteValueDictionary.Any方法代码示例

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


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

示例1: Generate

        public Uri Generate(RequestContext requestContext, INavigatable navigatable, RouteValueDictionary routeValues)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException(nameof(requestContext));
            }

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

            var urlHelper = new UrlHelper(requestContext);

            if (!String.IsNullOrEmpty(navigatable.RouteName))
            {
                return new Uri(uriString: urlHelper.RouteUrl(navigatable.RouteName, routeValues));
            }
            
            if (!String.IsNullOrEmpty(navigatable.ControllerName) && !String.IsNullOrEmpty(navigatable.ActionName))
            {
                return new Uri(uriString: urlHelper.Action(navigatable.ActionName, navigatable.ControllerName, routeValues), uriKind: UriKind.Relative);
            }

            if (routeValues.Any())
            {
                return new Uri(uriString: urlHelper.RouteUrl(routeValues));
            }

            return null;
        }
开发者ID:VlaTo,项目名称:EmpRe.NET,代码行数:31,代码来源:GridUrlGenerator.cs

示例2: Generate

        public static string Generate(RequestContext requestContext, NavigationRequest navigationItem, RouteValueDictionary routeValues)
        {
            if (requestContext == null)
                throw new ArgumentNullException("requestContext");
            if (navigationItem == null)
                throw new ArgumentNullException("navigationItem");

            var urlHelper = new UrlHelper(requestContext);
            string generatedUrl = null;

            if (!string.IsNullOrEmpty(navigationItem.RouteName))
            {
                generatedUrl = urlHelper.RouteUrl(navigationItem.RouteName, routeValues);
            }
            else if (!string.IsNullOrEmpty(navigationItem.ControllerName) && !string.IsNullOrEmpty(navigationItem.ActionName))
            {
                generatedUrl = urlHelper.Action(navigationItem.ActionName, navigationItem.ControllerName, routeValues, null, null);
            }
            else if (!string.IsNullOrEmpty(navigationItem.Url))
            {
                generatedUrl = navigationItem.Url.StartsWith("~/", StringComparison.Ordinal) 
                    ? urlHelper.Content(navigationItem.Url) 
                    : navigationItem.Url;
            }
            else if (routeValues.Any())
            {
                generatedUrl = urlHelper.RouteUrl(routeValues);
            }

            return generatedUrl;

        }
开发者ID:modulexcite,项目名称:FluentHtml,代码行数:32,代码来源:UrlGenerator.cs

示例3: Generate

        public string Generate(RequestContext requestContext, INavigatable navigationItem, RouteValueDictionary routeValues)
        {
            Guard.IsNotNull(requestContext, "requestContext");
            Guard.IsNotNull(navigationItem, "navigationItem");

            UrlHelper urlHelper = new UrlHelper(requestContext);
            string generatedUrl = null;

            if (!string.IsNullOrEmpty(navigationItem.RouteName))
            {
                generatedUrl = urlHelper.RouteUrl(navigationItem.RouteName, routeValues);
            }
            else if (!string.IsNullOrEmpty(navigationItem.ControllerName) && !string.IsNullOrEmpty(navigationItem.ActionName))
            {
                generatedUrl = urlHelper.Action(navigationItem.ActionName, navigationItem.ControllerName, routeValues, null, null);
            }
            else if (!string.IsNullOrEmpty(navigationItem.Url))
            {
                generatedUrl = navigationItem.Url.StartsWith("~/", StringComparison.Ordinal) ?
                               urlHelper.Content(navigationItem.Url) :
                               navigationItem.Url;
            }
            else if (routeValues.Any())
            {
                generatedUrl = urlHelper.RouteUrl(routeValues);
            }

            return generatedUrl;
        }
开发者ID:hazzik,项目名称:telerikaspnetmvc,代码行数:29,代码来源:UrlGenerator.cs

示例4: Create

        public static ExpandoObject Create(object values)
        {
            dynamic expandoObject = new ExpandoObject();
            if (values == null)
            {
                return expandoObject;
            }

            bool isPrimitiveType = GetIsPrimitiveType(values);
            if (isPrimitiveType)
            {
                expandoObject.Value = values;
                return expandoObject;
            }

            var dictionaryValues = new RouteValueDictionary(values);
            if (!dictionaryValues.Any())
            {
                return expandoObject;
            }

            var expandoDictionary = expandoObject as IDictionary<string, object>;
            foreach (var value in dictionaryValues)
            {
                expandoDictionary.Add(value.Key, value.Value);
            }

            return expandoObject;
        }
开发者ID:sebnilsson,项目名称:WikiDown,代码行数:29,代码来源:DynamicHelper.cs

示例5: getConstraints

        protected RouteValueDictionary getConstraints()
        {
            var dictionary = new RouteValueDictionary();
            if (_httpMethods.Any())
            {
                dictionary.Add(HTTP_METHOD_CONSTRAINT, new HttpMethodConstraint(_httpMethods.ToArray()));
            }

            _constraints.Each(dictionary.Add);

            return dictionary.Any() ? dictionary : null;
        }
开发者ID:mtscout6,项目名称:fubumvc,代码行数:12,代码来源:RouteDefinition.cs

示例6: GenerateUrl

        public static string GenerateUrl(this INavigatable navigatable, 
            RequestContext requestContext, 
            RouteValueDictionary routeValues = null)
        {
            var urlHelper = new UrlHelper(requestContext);
            string str = null;

            if (routeValues != null)
            {
                if (routeValues.Any())
                {
                    navigatable.RouteValues.Merge((IDictionary<string, object>)routeValues);
                }
            }
            routeValues = navigatable.RouteValues;

            var hasParam = false;
            var param = navigatable.ModifiedParam;
            if (param != null && param.HasValue() && param.Value != null)
            {
                routeValues[param.Name] = param.Value;
                hasParam = true;
            }

            if (!string.IsNullOrEmpty(navigatable.RouteName))
            {
                return urlHelper.RouteUrl(navigatable.RouteName, routeValues);
            }

            if (!string.IsNullOrEmpty(navigatable.ControllerName) && !string.IsNullOrEmpty(navigatable.ActionName))
            {
                return urlHelper.Action(navigatable.ActionName, navigatable.ControllerName, routeValues, null, null);
            }

            if (!string.IsNullOrEmpty(navigatable.ActionName))
            {
                return urlHelper.Action(navigatable.ActionName, routeValues);
            }

            if (!string.IsNullOrEmpty(navigatable.Url))
            {
                return (!navigatable.Url.StartsWith("~/", StringComparison.Ordinal) ? navigatable.Url : urlHelper.Content(navigatable.Url));
            }

            //if (routeValues == null)
            //{
            //    routeValues = new RouteValueDictionary();
            //    if (navigatable.RouteValues.Any())
            //    {
            //        routeValues.Merge((IDictionary<string, object>)navigatable.RouteValues);
            //    }
            //}

            if (hasParam)
            {
                var booleanParamNames = param.BooleanParamNames;

                foreach (var key in requestContext.HttpContext.Request.QueryString.AllKeys.Where(key => key != null))
                {
                    var value = requestContext.HttpContext.Request.QueryString[key];
                    if (booleanParamNames.Contains(key, StringComparer.InvariantCultureIgnoreCase))
                    {
                        // little hack here due to ugly MVC implementation
                        // find more info here: http://www.mindstorminteractive.com/blog/topics/jquery-fix-asp-net-mvc-checkbox-truefalse-value/
                        if (!String.IsNullOrEmpty(value) && value.Equals("true,false", StringComparison.InvariantCultureIgnoreCase))
                        {
                            value = "true";
                        }
                    }
                    routeValues[key] = value;
                }

                routeValues[param.Name] = param.Value;

                return UrlHelper.GenerateUrl(null, null, null, routeValues, RouteTable.Routes, requestContext, true);
            }

            if (routeValues.Any())
            {
                str = urlHelper.RouteUrl(routeValues);
            }

            return str;
        }
开发者ID:GloriousOnion,项目名称:SmartStoreNET,代码行数:84,代码来源:NavigatableExtensions.cs

示例7: MergeRouteData

 public void MergeRouteData(RouteValueDictionary source, RouteValueDictionary destination)
 {
     foreach (var item in source)
     {
         if (destination.Any(i => i.Key == item.Key))
         {
             destination[item.Key] = item.Value;
         }
         else
         {
             destination.Add(item.Key, item.Value);
         }
     }
 }
开发者ID:wenbinke,项目名称:susucms,代码行数:14,代码来源:PageRouteParser.cs

示例8: Generate

        private static string Generate(RequestContext requestContext, SiteMapNode navigationItem, RouteValueDictionary routeValues)
        {
            Check.Argument.IsNotNull(requestContext, "requestContext");
            Check.Argument.IsNotNull(navigationItem, "navigationItem");

            var urlHelper = new UrlHelper(requestContext);
            string generatedUrl = null;

            if (!string.IsNullOrEmpty(navigationItem.RouteName))
            {
                generatedUrl = urlHelper.RouteUrl(navigationItem.RouteName, routeValues);
            }
            else if (!string.IsNullOrEmpty(navigationItem.ControllerName) && !string.IsNullOrEmpty(navigationItem.ActionName))
            {
                generatedUrl = urlHelper.Action(navigationItem.ActionName, navigationItem.ControllerName, routeValues, null, null);
            }
            else if (!string.IsNullOrEmpty(navigationItem.Url))
            {
                generatedUrl = navigationItem.Url.StartsWith("~/", StringComparison.Ordinal) ?
                               urlHelper.Content(navigationItem.Url) :
                               navigationItem.Url;
                //var rgx = new Regex(@"#.*$");
                //if(rgx.IsMatch(generatedUrl))
                //{
                //    generatedUrl = rgx.Match(generatedUrl).Value;
                //}
            }
            else if (routeValues.Any())
            {
                generatedUrl = urlHelper.RouteUrl(routeValues);
            }

            return generatedUrl;
        }
开发者ID:gowhy,项目名称:LoveBank,代码行数:34,代码来源:SiteMapNodeExtensions.cs


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