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


C# HttpRouteValueDictionary类代码示例

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


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


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