本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}