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

C# HttpRouteValueDictionary类代码示例

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

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



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

示例1: MapODataRoute

        /// <summary>
        /// Map odata route with query string or header constraints
        /// </summary>
        public static void MapODataRoute(
            this HttpRouteCollection routes,
            string routeName,
            string routePrefix,
            IEdmModel model,
            IODataPathHandler pathHandler,
            IEnumerable<IODataRoutingConvention> routingConventions,
            object queryConstraints,
            object headerConstraints)
        {
            if (routes == null)
            {
                throw new ArgumentNullException("routes");
            }

            string routeTemplate = string.IsNullOrEmpty(routePrefix) ? ODataRouteConstants.ODataPathTemplate : (routePrefix + "/" + ODataRouteConstants.ODataPathTemplate);
            ODataVersionRouteConstraint routeConstraint = new ODataVersionRouteConstraint(pathHandler, model, routeName, routingConventions, queryConstraints, headerConstraints);
            var constraints = new HttpRouteValueDictionary();
            constraints.Add(ODataRouteConstants.ConstraintName, routeConstraint);
            routes.MapHttpRoute(
                routeName,
                routeTemplate,
                defaults: null,
                constraints: constraints);
        }
开发者ID:andreychizhov,项目名称:microsoft-aspnet-samples,代码行数:28,代码来源:ODataVersionRouteExtensions.cs


示例2: Register

        public static void Register(HttpConfiguration config)
        {
            // Web API 配置和服务

            // Web API 路由
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }//,
                //constraints:new{sss=new HttpMethodConstraint(HttpMethod.Post)}

            );
            HttpRouteValueDictionary defaults = new HttpRouteValueDictionary();
            //defaults.Add("controller", "Demo");
            //defaults.Add("action", "Get");
            defaults.Add("val", 0);
            HttpRouteValueDictionary constraints = new HttpRouteValueDictionary();
            constraints.Add("val",new DoubleRouteConstraint());

            HttpRoute route = new HttpRoute("customer/{controller}/{action}/{val}", defaults, constraints);

            config.Routes.Add("CustomerApi",route);
        }
开发者ID:BarlowDu,项目名称:WebAPI,代码行数:25,代码来源:WebApiConfig.cs


示例3: Register

 public static void Register(HttpConfiguration config)
 {
     var emptyDictionary = new HttpRouteValueDictionary();
     // Add our one HttpMessageHandler to the root path.
     config.Routes.MapHttpRoute("index", "", emptyDictionary, emptyDictionary,
         new HelloWorldHandler());
 }
开发者ID:SurferJeffAtGoogle,项目名称:getting-started-dotnet,代码行数:7,代码来源:WebApiConfig.cs


示例4: BuildHttpRoute

 /// <summary>
 /// Builds an <see cref="IHttpRoute"/>.
 /// </summary>
 /// <param name="routeTemplate">The detokenized route template.</param>
 /// <param name="defaults">The route defaults.</param>
 /// <param name="constraints">The route constraints.</param>
 /// <param name="actions">The actions to invoke for the route.</param>
 /// <returns>The generated <see cref="IHttpRoute"/>.</returns>
 public virtual IHttpRoute BuildHttpRoute(
     string routeTemplate,
     HttpRouteValueDictionary defaults,
     HttpRouteValueDictionary constraints,
     IEnumerable<ReflectedHttpActionDescriptor> actions)
 {
     return new HttpDirectRoute(routeTemplate, defaults, constraints, actions);
 }
开发者ID:jaceenet,项目名称:aspnetwebstack,代码行数:16,代码来源:HttpRouteBuilder.cs


示例5: HttpAttributeRoute

 /// <summary>
 /// Route used by the AttributeRouting framework in self-host projects.
 /// </summary>
 public HttpAttributeRoute(string url,
     HttpRouteValueDictionary defaults,
     HttpRouteValueDictionary constraints,
     HttpRouteValueDictionary dataTokens,
     HttpAttributeRoutingConfiguration configuration)
     : base(url, defaults, constraints, dataTokens)
 {
     _configuration = configuration;
 }
开发者ID:kamranayub,项目名称:AttributeRouting,代码行数:12,代码来源:HttpAttributeRoute.cs


示例6: ODataVersionRouteConstraint

 public ODataVersionRouteConstraint(
     string routeName,
     object queryConstraints,
     object headerConstraints)
     : base(routeName)
 {
     QueryStringConstraints = new HttpRouteValueDictionary(queryConstraints);
     HeaderConstraints = new HttpRouteValueDictionary(headerConstraints);
 }
开发者ID:rbeauchamp,项目名称:Swashbuckle.OData,代码行数:9,代码来源:ODataVersionRouteConstraint.cs


示例7: HttpAttributeRoute

 /// <summary>
 /// Route used by the AttributeRouting framework in self-host projects.
 /// </summary>
 public HttpAttributeRoute(string url,
                           HttpRouteValueDictionary defaults,
                           HttpRouteValueDictionary constraints,
                           HttpRouteValueDictionary dataTokens,
                           HttpConfigurationBase configuration)
     : base(url, defaults, constraints, dataTokens, configuration.MessageHandler)
 {
     _configuration = configuration;
 }
开发者ID:gregmac,项目名称:AttributeRouting,代码行数:12,代码来源:HttpAttributeRoute.cs


示例8: GetPrecedence

 private static decimal GetPrecedence(string attributeRouteTemplate)
 {
     DefaultInlineConstraintResolver resolver = new DefaultInlineConstraintResolver();
     HttpRouteValueDictionary defaults = new HttpRouteValueDictionary();
     HttpRouteValueDictionary constraints = new HttpRouteValueDictionary();
     string standardRouteTemplate = InlineRouteTemplateParser.ParseRouteTemplate(attributeRouteTemplate,
         defaults, constraints, new DefaultInlineConstraintResolver());
     HttpParsedRoute parsedRoute = HttpRouteParser.Parse(standardRouteTemplate);
     return parsedRoute.GetPrecedence(constraints);
 }
开发者ID:normalian,项目名称:aspnetwebstack,代码行数:10,代码来源:HttpParsedRouteTests.cs


示例9: ODataRoute

 /// <summary>
 /// Initializes a new instance of the <see cref="ODataRoute" /> class.
 /// </summary>
 /// <param name="routePrefix">The route prefix.</param>
 /// <param name="pathConstraint">The OData path constraint.</param>
 /// <param name="defaults">The default values for the route.</param>
 /// <param name="constraints">The route constraints.</param>
 /// <param name="dataTokens">The data tokens.</param>
 /// <param name="handler">The message handler for the route.</param>
 public ODataRoute(
     string routePrefix,
     ODataPathRouteConstraint pathConstraint,
     HttpRouteValueDictionary defaults,
     HttpRouteValueDictionary constraints,
     HttpRouteValueDictionary dataTokens,
     HttpMessageHandler handler)
     : this(routePrefix, (IHttpRouteConstraint)pathConstraint, defaults, constraints, dataTokens, handler)
 {
 }
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:19,代码来源:ODataRoute.cs


示例10: HttpRoute

        public HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens)
        {
            _routeTemplate = String.IsNullOrWhiteSpace(routeTemplate) ? String.Empty : routeTemplate;
            _defaults = defaults ?? new HttpRouteValueDictionary();
            _constraints = constraints ?? new HttpRouteValueDictionary();
            _dataTokens = dataTokens ?? new HttpRouteValueDictionary();

            // The parser will throw for invalid routes. 
            _parsedRoute = HttpRouteParser.Parse(_routeTemplate);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:10,代码来源:HttpRoute.cs


示例11: TestValue

        protected bool TestValue(IHttpRouteConstraint constraint, object value)
        {
            HttpRequestMessage httpRequestMessage = new HttpRequestMessage();
            HttpRoute httpRoute = new HttpRoute();
            const string parameterName = "fake";
            HttpRouteValueDictionary values = new HttpRouteValueDictionary { { parameterName, value } };
            const HttpRouteDirection httpRouteDirection = HttpRouteDirection.UriResolution;

            return constraint.Match(httpRequestMessage, httpRoute, parameterName, values, httpRouteDirection);
        }        
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:10,代码来源:HttpRouteConstraintTestBase.cs


示例12: MapHttpRoute

 /// <summary>
 /// 
 /// </summary>
 /// <param name="routes"></param>
 /// <param name="name"></param>
 /// <param name="routeTemplate"></param>
 /// <param name="defaults"></param>
 /// <param name="constraints"></param>
 /// <param name="handler"></param>
 /// <param name="namespaces"></param>
 /// <returns></returns>
 public static IHttpRoute MapHttpRoute(this HttpRouteCollection routes, string name, string routeTemplate, object defaults, object constraints, HttpMessageHandler handler, string[] namespaces)
 {
     if (routes == null)
     {
         throw new ArgumentNullException("routes");
     }
     var routeValue = new HttpRouteValueDictionary(new { Namespace = namespaces });//设置路由值  
     var route = routes.CreateRoute(routeTemplate, new HttpRouteValueDictionary(defaults), new HttpRouteValueDictionary(constraints), routeValue, handler);
     routes.Add(name, route);
     return route;
 }  
开发者ID:Indifer,项目名称:Raven.AspNetUtil,代码行数:22,代码来源:HttpRouteCollectionExtended.cs


示例13: HttpRoute

        public HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens, HttpMessageHandler handler)
        {
            _routeTemplate = routeTemplate == null ? String.Empty : routeTemplate;
            _defaults = defaults ?? new HttpRouteValueDictionary();
            _constraints = constraints ?? new HttpRouteValueDictionary();
            _dataTokens = dataTokens ?? new HttpRouteValueDictionary();
            Handler = handler;

            // The parser will throw for invalid routes.
            ParsedRoute = HttpRouteParser.Parse(RouteTemplate);
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:11,代码来源:HttpRoute.cs


示例14: Constructor_IsCaseInsensitive

        public void Constructor_IsCaseInsensitive()
        {
            // Arrange
            HttpRouteValueDictionary routeValues = new HttpRouteValueDictionary();

            // Act
            routeValues.Add("KEY", null);

            // Assert
            Assert.True(routeValues.ContainsKey("key"));
        }
开发者ID:reza899,项目名称:aspnetwebstack,代码行数:11,代码来源:HttpRouteValueDictionaryTest.cs


示例15: ODataVersionRouteConstraint

 public ODataVersionRouteConstraint(
     IODataPathHandler pathHandler,
     IEdmModel model,
     string routeName,
     IEnumerable<IODataRoutingConvention> routingConventions,
     object queryConstraints,
     object headerConstraints)
     : base(pathHandler, model, routeName, routingConventions)
 {
     QueryStringConstraints = new HttpRouteValueDictionary(queryConstraints);
     HeaderConstraints = new HttpRouteValueDictionary(headerConstraints);
 }
开发者ID:bigred8982,项目名称:Swashbuckle.OData,代码行数:12,代码来源:ODataVersionRouteConstraint.cs


示例16: HttpDirectRoute

 /// <summary>
 /// Initializes a new instance of the <see cref="HttpDirectRoute" /> class.
 /// </summary>
 /// <param name="routeTemplate">The route template.</param>
 /// <param name="defaults">The default values.</param>
 /// <param name="constraints">The route constraints.</param>
 /// <param name="actions">The actions that are reachable via this route.</param>
 public HttpDirectRoute(
     string routeTemplate,
     HttpRouteValueDictionary defaults,
     HttpRouteValueDictionary constraints,
     IEnumerable<ReflectedHttpActionDescriptor> actions)
     : base(routeTemplate, defaults: defaults, constraints: constraints, dataTokens: null, handler: null)
 {
     if (actions != null)
     {
         Actions = actions.AsArray();
         DataTokens[RouteKeys.ActionsDataTokenKey] = Actions;
     }
 }
开发者ID:RhysC,项目名称:aspnetwebstack,代码行数:20,代码来源:HttpDirectRoute.cs


示例17: MapHttpRoute

        /// <summary>
        /// Maps the specified route template and sets default route values, constraints, and end-point message handler.
        /// </summary>
        /// <param name="routes">A collection of routes for the application.</param>
        /// <param name="name">The name of the route to map.</param>
        /// <param name="routeTemplate">The route template for the route.</param>
        /// <param name="defaults">An object that contains default route values.</param>
        /// <param name="constraints">A set of expressions that specify values for <paramref name="routeTemplate"/>.</param>
        /// <param name="handler">The handler to which the request will be dispatched.</param>
        /// <returns>A reference to the mapped route.</returns>
        public static IHttpRoute MapHttpRoute(this HttpRouteCollection routes, string name, string routeTemplate, object defaults, object constraints, HttpMessageHandler handler)
        {
            if (routes == null)
            {
                throw Error.ArgumentNull("routes");
            }

            HttpRouteValueDictionary defaultsDictionary = new HttpRouteValueDictionary(defaults);
            HttpRouteValueDictionary constraintsDictionary = new HttpRouteValueDictionary(constraints);
            IHttpRoute route = routes.CreateRoute(routeTemplate, defaultsDictionary, constraintsDictionary, dataTokens: null, handler: handler);
            routes.Add(name, route);
            return route;
        }
开发者ID:jaceenet,项目名称:aspnetwebstack,代码行数:23,代码来源:HttpRouteCollectionExtensions.cs


示例18: MapHttpRoute

        /// <summary>
        /// Maps the specified route template and sets default route values, constraints, namespaces, and end-point message handler.
        /// </summary>
        /// <param name="routes">A collection of routes for the application.</param>
        /// <param name="name">The name of the route to map.</param>
        /// <param name="routeTemplate">The route template for the route.</param>
        /// <param name="defaults">An object that contains default route values.</param>
        /// <param name="constraints">A set of expressions that specify values for <paramref name="routeTemplate"/>.</param>
        /// <param name="handler">The handler to which the request will be dispatched.</param>
        /// <returns>A reference to the mapped route.</returns>
        public static Route MapHttpRoute(this RouteCollection routes, string name, string routeTemplate, object defaults, object constraints, HttpMessageHandler handler)
        {
            if (routes == null)
            {
                throw Error.ArgumentNull("routes");
            }

            HttpRouteValueDictionary defaultsDictionary = new HttpRouteValueDictionary(defaults);
            HttpRouteValueDictionary constraintsDictionary = new HttpRouteValueDictionary(constraints);
            HostedHttpRoute httpRoute = (HostedHttpRoute)GlobalConfiguration.Configuration.Routes.CreateRoute(routeTemplate, defaultsDictionary, constraintsDictionary, dataTokens: null, handler: handler);
            Route route = httpRoute.OriginalRoute;
            routes.Add(name, route);
            return route;
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:24,代码来源:RouteCollectionExtensions.cs


示例19: GetVirtualPath_GeneratesPathWithoutRouteData

        public void GetVirtualPath_GeneratesPathWithoutRouteData()
        {
            var route = new HttpRoute("{controller}");
            var request = new HttpRequestMessage();
            var values = new HttpRouteValueDictionary()
            {
                { "httproute", true },
                { "controller", "Customers" }
            };

            IHttpVirtualPathData virtualPath = route.GetVirtualPath(request, values);

            Assert.NotNull(virtualPath);
            Assert.Equal("Customers", virtualPath.VirtualPath);
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:15,代码来源:HttpRouteTest.cs


示例20: MapODataRoute

        /// <summary>
        /// Maps the specified OData route.
        /// </summary>
        /// <param name="routes">A collection of routes for the application.</param>
        /// <param name="routeName">The name of the route to map.</param>
        /// <param name="routePrefix">The prefix to add to the OData route's path template.</param>
        /// <param name="model">The EDM model to use for parsing OData paths.</param>
        /// <param name="pathHandler">The <see cref="IODataPathHandler"/> to use for parsing the OData path.</param>
        /// <param name="routingConventions">The OData routing conventions to use for controller and action selection.</param>
        public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix, IEdmModel model,
            IODataPathHandler pathHandler, IEnumerable<IODataRoutingConvention> routingConventions)
        {
            if (routes == null)
            {
                throw Error.ArgumentNull("routes");
            }

            string routeTemplate = String.IsNullOrEmpty(routePrefix) ?
                ODataRouteConstants.ODataPathTemplate :
                routePrefix + "/" + ODataRouteConstants.ODataPathTemplate;
            IHttpRouteConstraint routeConstraint = new ODataPathRouteConstraint(pathHandler, model, routeName, routingConventions);
            HttpRouteValueDictionary constraintDictionary = new HttpRouteValueDictionary() { { ODataRouteConstants.ConstraintName, routeConstraint } };
            routes.MapHttpRoute(routeName, routeTemplate, defaults: null, constraints: constraintDictionary);
        }
开发者ID:naulizzang,项目名称:aspnetwebstack,代码行数:24,代码来源:ODataHttpRouteCollectionExtensions.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# HttpServer类代码示例发布时间:2022-05-24
下一篇:
C# HttpRouteDirection类代码示例发布时间: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