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


C# RouteValueDictionary类代码示例

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


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


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