• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# RouteValueDictionary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetPageRoute

 public static RouteValueDictionary GetPageRoute(this RequestContext requestContext, ContentReference contentLink)
 {
     var values = new RouteValueDictionary();
     values[RoutingConstants.NodeKey] = contentLink;
     values[RoutingConstants.LanguageKey] = ContentLanguage.PreferredCulture.Name;
     return values;
 }
开发者ID:ojarsb,项目名称:EpiRatingAlloySite,代码行数:7,代码来源:UrlHelpers.cs


示例2: GetRouteDescriptorKey

        public string GetRouteDescriptorKey(HttpContextBase httpContext, RouteBase routeBase) {
            var route = routeBase as Route;
            var dataTokens = new RouteValueDictionary();

            if (route != null) {
                dataTokens = route.DataTokens;
            }
            else {
            var routeData = routeBase.GetRouteData(httpContext);

                if (routeData != null) {
                    dataTokens = routeData.DataTokens;
                }
            }

            var keyBuilder = new StringBuilder();

            if (route != null) {
                keyBuilder.AppendFormat("url={0};", route.Url);
            }

            // the data tokens are used in case the same url is used by several features, like *{path} (Rewrite Rules and Home Page Provider)
            if (dataTokens != null) {
                foreach (var key in dataTokens.Keys) {
                    keyBuilder.AppendFormat("{0}={1};", key, dataTokens[key]);
                }
            }

            return keyBuilder.ToString().ToLowerInvariant();
        }
开发者ID:mikmakcar,项目名称:orchard_fork_learning,代码行数:30,代码来源:CacheService.cs


示例3: RegisterRoutes

 public void RegisterRoutes(RouteCollection routes)
 {
     //Register 1 route
     var basePath = Config.GetBasePath();
     var constrasints = new RouteValueDictionary {{"method", new ApiHttpMethodConstraint("OPTIONS")}};
     routes.Add(new Route(basePath + "{*path}", null, constrasints, new ApiAccessRouteHandler()));
 }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:7,代码来源:ApiAccessControlRouteRegistrator.cs


示例4: OnActionExecuting

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            var principal = HttpContext.Current.User as IClaimsPrincipal;
            var buffer = new StringBuilder();

            if (principal != null && principal.Identity.IsAuthenticated)
            {
                foreach (var claim in Claims)
                {
                    if (!principal.Identities[0].Claims.Any(c => c.ClaimType == claim))
                    {
                        buffer.AppendLine(String.Format("Claim '{0}' not provided.", claim));
                    }
                }

                if (buffer.Length > 0)
                {
                    var redirectTargetDictionary = new RouteValueDictionary
                        {
                            {"action", "Error"},
                            {"controller", "Home"},
                            {"message", buffer.ToString()}
                        };

                    filterContext.Result = new RedirectToRouteResult(redirectTargetDictionary);
                }
            }
        }
开发者ID:luismdcp,项目名称:PROMP11-08-Security.luismdcp,代码行数:29,代码来源:RequireClaimsAttribute.cs


示例5: GetVirtualPath

        public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
        {
            VirtualPathData path = base.GetVirtualPath(requestContext, values);

            if (path != null)
            {
                string virtualPath = path.VirtualPath;
                var lastIndexOf = virtualPath.LastIndexOf("?");

                if (lastIndexOf != 0)
                {
                    if (lastIndexOf > 0)
                    {
                        string leftPart = virtualPath.Substring(0, lastIndexOf).ToLowerInvariant();
                        string queryPart = virtualPath.Substring(lastIndexOf);
                        path.VirtualPath = leftPart + queryPart;
                    }
                    else
                    {
                        path.VirtualPath = path.VirtualPath.ToLowerInvariant();
                    }
                }
            }

            return path;
        }
开发者ID:yimogit,项目名称:YimoFramework,代码行数:26,代码来源:LowercaseRoute.cs


示例6: GetOutput

        private static string GetOutput(object tokenReplacements)
        {
            // Read the contents of the html template.
            var assembly = Assembly.GetExecutingAssembly();
            var fileName = "{0}.LogRoutes.html".FormatWith(typeof(LogRoutesHandler).Namespace);
            string fileContent;
            using (var stream = assembly.GetManifestResourceStream(fileName))
            {
                if (stream == null)
                    throw new AttributeRoutingException(
                        "The file \"{0}\" cannot be found as an embedded resource.".FormatWith(fileName));

                using (var reader = new StreamReader(stream))
                    fileContent = reader.ReadToEnd();
            }

            // Replace tokens in the template with appropriate content
            var outputBuilder = new StringBuilder(fileContent);

            var tokenReplacementsDictionary = new RouteValueDictionary(tokenReplacements);
            foreach (var key in tokenReplacementsDictionary.Keys)
                outputBuilder.Replace("{{{0}}}".FormatWith(key), tokenReplacementsDictionary[key].ToString());

            return outputBuilder.ToString();
        }
开发者ID:xps,项目名称:AttributeRouting,代码行数:25,代码来源:LogRoutesHandler.cs


示例7: 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


示例8: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            var def = new RouteValueDictionary(new { user = "demo" });
            var reg = new RouteValueDictionary(new { user = "\\w+" });

            // Register a route for Page/{User}
            routes.MapPageRoute(
               "user-page", // Route name
               "w/{user}", // Route URL
               "~/Pv.aspx", // Web page to handle route
               true,
               def,
               reg
            );
            // Register a route for Page/{User}
            routes.MapPageRoute(
               "user-card", // Route name
               "c/{user}", // Route URL
               "~/Cv.aspx", // Web page to handle route
               true,
               def,
               reg
            );
            // Register a route for Page/{User}
            routes.MapPageRoute(
               "user-imgs", // Route name
               "p/{user}", // Route URL
               "~/Id.aspx", // Web page to handle route
               true,
               def,
               reg
            );
        }
开发者ID:burstas,项目名称:rmps,代码行数:33,代码来源:Global.asax.cs


示例9: Match

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) {

            object value;
            if (values.TryGetValue(parameterName, out value)) {
                var parameterValue = Convert.ToString(value);

                var path = FindPath(parameterValue);
                if (path == null) {
                    return false;
                }

                var archiveData = FindArchiveData(parameterValue);
                if (archiveData == null) {
                    return false;
                }

                try {
                    // is this a valid date ?
                    archiveData.ToDateTime();
                }
                catch {
                    return false;
                }

                var autoroute = _pathResolutionService.GetPath(path);

                return autoroute != null && autoroute.Is<BlogPart>();
            }

            return false;
        }
开发者ID:Zlatinsz,项目名称:podnebeto,代码行数:31,代码来源:ArchiveConstraint.CS


示例10: GetConfigurationRoute

 /// <summary>
 /// Gets a route for provider configuration
 /// </summary>
 /// <param name="actionName">Action name</param>
 /// <param name="controllerName">Controller name</param>
 /// <param name="routeValues">Route values</param>
 public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
 {
     // no configuration required
     actionName = null;
     controllerName = null;
     routeValues = null;
 }
开发者ID:tomvanenckevort,项目名称:NopCommerce.MultipleParentCategories,代码行数:13,代码来源:MultipleParentsPlugin.cs


示例11: Match

 /// <summary>
 /// 
 /// </summary>
 /// <param name="httpContext"></param>
 /// <param name="route"></param>
 /// <param name="parameterName"></param>
 /// <param name="values"></param>
 /// <param name="routeDirection"></param>
 /// <returns></returns>
 public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
 {
     if (values[parameterName].ToString().ToLower() == "rqitems")
         return true;
     else
         return false;
 }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:16,代码来源:RouteConstraints.cs


示例12: AddNodeRecursive

        private SiteMapNode AddNodeRecursive(XmlNode xmlNode, SiteMapNode parent, RequestContext context)
        {
            var routeValues = (from XmlNode attrib in xmlNode.Attributes
                               where !reservedNames.Contains(attrib.Name.ToLower())
                               select new { attrib.Name, attrib.Value }).ToDictionary(x => x.Name, x => (object)x.Value);

            RouteValueDictionary routeDict = new RouteValueDictionary(routeValues);
            VirtualPathData virtualPathData = RouteTable.Routes.GetVirtualPath(context, routeDict);

            if (virtualPathData == null)
            {
                string message = "RoutingSiteMapProvider is unable to locate Route for " +
                                 "Controller: '" + routeDict["controller"] + "', Action: '" + routeDict["action"] + "'. " +
                                 "Make sure a route has been defined for this SiteMap Node.";
                throw new InvalidOperationException(message);
            }

            string url = virtualPathData.VirtualPath;

            string title = xmlNode.Attributes["title"].Value;
            SiteMapNode node = new SiteMapNode(this, Guid.NewGuid().ToString(), url, title);

            base.AddNode(node, parent);

            foreach (XmlNode childNode in xmlNode.ChildNodes)
            {
                AddNodeRecursive(childNode, node, context);
            }

            return node;
        }
开发者ID:Sironfoot,项目名称:T3ME,代码行数:31,代码来源:RoutingSiteMapProvider.cs


示例13: MapAreaRoute

        // TODO: Remove when https://github.com/aspnet/Mvc/issues/4846 is fixed
        public static IRouteBuilder MapAreaRoute(this IRouteBuilder routeBuilder,
            string name,
            string area,
            string template,
            string controller,
            string action)
        {
            if (routeBuilder == null)
            {
                throw new ArgumentNullException(nameof(routeBuilder));
            }

            if (string.IsNullOrEmpty(area))
            {
                throw new ArgumentException(nameof(area));
            }

            var defaultsDictionary = new RouteValueDictionary();
            defaultsDictionary["area"] = area;
            defaultsDictionary["controller"] = controller;
            defaultsDictionary["action"] = action;

            var constraintsDictionary = new RouteValueDictionary();
            constraintsDictionary["area"] = new StringRouteConstraint(area);

            routeBuilder.MapRoute(name, template, defaultsDictionary, constraintsDictionary, null);
            return routeBuilder;
        }
开发者ID:jchenga,项目名称:Orchard2,代码行数:29,代码来源:RouteBuilderExtensions.cs


示例14: Match

 // To only allow *supported* cultures as the first part of the route, instead of  anything in the format xx or xx-xx comment the lower method
 // and uncomment this one, and make CultureManager.CultureIsSupported public.
 //public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
 //{
 //    if (!values.ContainsKey(parameterName))
 //        return false;
 //    string potentialCultureName = (string)values[parameterName];
 //    return CultureManager.CultureIsSupported(potentialCultureName);
 //}
 public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
 {
     if (!values.ContainsKey(parameterName))
         return false;
     string potentialCultureName = (string)values[parameterName];
     return CultureFormatChecker.FormattedAsCulture(potentialCultureName);
 }
开发者ID:babelfish42,项目名称:OnlineShop,代码行数:16,代码来源:CultureRouteConstraint.cs


示例15: BuildLink

 public ActionLink BuildLink(Theme theme)
 {
     RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
     routeValueDictionary.Add("id", theme.Id);
     ActionLink actionLink = new ActionLink("Play", "Training", routeValueDictionary);
     return actionLink;
 }
开发者ID:supermuk,项目名称:iudico,代码行数:7,代码来源:TestingService.cs


示例16: MergeRouteValues

 public static RouteValueDictionary MergeRouteValues(string actionName, string controllerName,
     RouteValueDictionary implicitRouteValues,
     RouteValueDictionary routeValues,
     bool includeImplicitMvcValues)
 {
     var routeValueDictionary = new RouteValueDictionary();
     if (includeImplicitMvcValues)
     {
         object obj;
         if (implicitRouteValues != null && implicitRouteValues.TryGetValue("action", out obj))
         {
             routeValueDictionary["action"] = obj;
         }
         if (implicitRouteValues != null && implicitRouteValues.TryGetValue("controller", out obj))
         {
             routeValueDictionary["controller"] = obj;
         }
     }
     if (routeValues != null)
     {
         foreach (var keyValuePair in GetRouteValues(routeValues))
         {
             routeValueDictionary[keyValuePair.Key] = keyValuePair.Value;
         }
     }
     if (actionName != null)
     {
         routeValueDictionary["action"] = actionName;
     }
     if (controllerName != null)
     {
         routeValueDictionary["controller"] = controllerName;
     }
     return routeValueDictionary;
 }
开发者ID:Cefa68000,项目名称:AttributeRouting,代码行数:35,代码来源:UrlHelperExtensions.cs


示例17: SubdomainAction

 public static string SubdomainAction(this UrlHelper urlHelper, string actionName, string controllerName,
     string areaName = "")
 {
     var routeValues = new RouteValueDictionary { { "area", areaName } };
     string baseUrl = GetDomainBase(urlHelper, null, actionName, controllerName, routeValues);
     return BuildUri(baseUrl, urlHelper.Action(actionName, controllerName, routeValues));
 }
开发者ID:Cefa68000,项目名称:AttributeRouting,代码行数:7,代码来源:UrlHelperExtensions.cs


示例18: Begin

        public static IDisposable Begin(string tagName, TextWriter writer, RouteValueDictionary htmlAttributes)
        {
            var tag = new TagBuilder(tagName);
            tag.MergeAttributes(htmlAttributes);

            return new TagWrapper(tag, writer);
        }
开发者ID:Biswo,项目名称:n2cms,代码行数:7,代码来源:TagWrapper.cs


示例19: VirtualPathContext

 /// <summary>
 /// Creates a new <see cref="VirtualPathContext"/>.
 /// </summary>
 /// <param name="httpContext">The <see cref="Http.HttpContext"/> associated with the current request.</param>
 /// <param name="ambientValues">The set of route values associated with the current request.</param>
 /// <param name="values">The set of new values provided for virtual path generation.</param>
 public VirtualPathContext(
     HttpContext httpContext,
     RouteValueDictionary ambientValues,
     RouteValueDictionary values)
     : this(httpContext, ambientValues, values, null)
 {
 }
开发者ID:leloulight,项目名称:Routing,代码行数:13,代码来源:VirtualPathContext.cs


示例20: ModalDialogActionLink

 /// <summary>
 /// The modal dialog action link.
 /// </summary>
 /// <param name="ajaxHelper">Um Helper Ajax.</param>
 /// <param name="linkText">O texto a ser exibido no link</param>
 /// <param name="actionName">A Action a ser executada quando o link for clicado</param>
 /// <param name="controllerName">O nome do controller</param>
 /// <param name="dialogTitle">O título do modal popUp a ser exibido</param>
 /// <param name="routeValues">Valores de Rota</param>
 /// <param name="htmlAttributes">html atributes</param>
 /// <param name="onSubmitJsCallback">
 /// Um Callback JS a ser executado após o submit
 /// <para></para>
 /// Este callback deve ser criado de forma a receber uma conjunto de dados no formato Json.
 /// Ex: function callback(data){}
 /// Para informar quais dados devem ser submetidos, deve-se retornar um <see cref="DialogResult(System.Web.Mvc.Controller,string,object)"/>, 
 /// endo o último parâmetro, um <see cref="object"/> que será serializado.
 /// Após a submissão do formulário, caso não seja especificado um callback, os dados serão descartados.
 /// </param>
 /// <returns>The <see cref="MvcHtmlString"/>.</returns>
 public static MvcHtmlString ModalDialogActionLink(
     this AjaxHelper ajaxHelper,
     string linkText,
     string actionName,
     string controllerName,
     string dialogTitle,
     RouteValueDictionary routeValues,
     IDictionary<string, object> htmlAttributes,
     string onSubmitJsCallback)
 {
     if (routeValues == null)
     {
         routeValues = new RouteValueDictionary();
     }
     
     var dialogDivId = Guid.NewGuid().ToString();
     return ajaxHelper.ActionLink(
         linkText,
         actionName,
         controllerName,
         routeValues: routeValues,
         ajaxOptions:
             new AjaxOptions
             {
                 UpdateTargetId = dialogDivId,
                 InsertionMode = InsertionMode.Replace,
                 HttpMethod = "GET",
                 OnBegin = string.Format(CultureInfo.InvariantCulture, "prepareModalDialog('{0}')", dialogDivId),
                 OnFailure = string.Format(CultureInfo.InvariantCulture, "clearModalDialog('{0}');alert('Ajax call failed')", dialogDivId),
                 OnSuccess = string.Format(CultureInfo.InvariantCulture, "openModalDialog('{0}', '{1}', {2})", dialogDivId, dialogTitle, onSubmitJsCallback)
             },
         htmlAttributes: htmlAttributes);
 }
开发者ID:jedielson,项目名称:Asp.NetMvc-BootstrapModal-Example,代码行数:53,代码来源:ModalDialogExtensions.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RoutedEvent类代码示例发布时间:2022-05-24
下一篇:
C# RouteHandler类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap