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


C# HttpRouteDirection类代码示例

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


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

示例1: Match

 public bool Match(
     HttpRequestMessage request,
     IHttpRoute route,
     string parameterName,
     IDictionary<string, object> values,
     HttpRouteDirection routeDirection) =>
         Match(parameterName, values);
开发者ID:KimberlyPhan,项目名称:Its.Cqrs,代码行数:7,代码来源:GuidConstraint.cs

示例2: Match

        public bool Match(System.Net.Http.HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary<string, object> values, HttpRouteDirection routeDirection)
        {
            if (values == null) // shouldn't ever hit this.
                return true;

            if (!values.ContainsKey(parameterName) || !values.ContainsKey(_id)) // make sure the parameter is there.
                return true;

            var action = values[parameterName].ToString().ToLower();
            if (string.IsNullOrEmpty(action)) // if the param key is empty in this case "action" add the method so it doesn't hit other methods like "GetStatus"
            {
                values[parameterName] = request.Method.ToString();
            }
            else if (string.IsNullOrEmpty(values[_id].ToString()))
            {
                var isidstr = true;
                array.ToList().ForEach(x =>
                {
                    if (action.StartsWith(x.ToLower()))
                        isidstr = false;
                });

                if (isidstr)
                {
                    values[_id] = values[parameterName];
                    values[parameterName] = request.Method.ToString();
                }
            }
            return true;
        }
开发者ID:ud7070,项目名称:UDTest,代码行数:30,代码来源:StartWithConstraint.cs

示例3: Match

        protected override bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary<string, object> values, HttpRouteDirection routeDirection)
        {
            if (routeDirection == HttpRouteDirection.UriGeneration)
                return true;

            return base.Match(request, route, parameterName, values, routeDirection);
        }
开发者ID:Cefa68000,项目名称:AttributeRouting,代码行数:7,代码来源:InboundHttpMethodConstraint.cs

示例4: Match

        public override bool Match(
            HttpRequestMessage request,
            IHttpRoute route,
            string parameterName,
            IDictionary<string, object> values,
            HttpRouteDirection routeDirection)
        {
            foreach (string key in HeaderConstraints.Keys)
            {
                if (!request.Headers.Contains(key)
                    || string.Compare(request.Headers.GetValues(key).FirstOrDefault(), HeaderConstraints[key].ToString(), true) != 0)
                {
                    return false;
                }
            }

            var queries = request.GetQueryNameValuePairs().ToDictionary(p => p.Key, p => p.Value);
            foreach (var key in QueryStringConstraints.Keys)
            {
                if (!queries.ContainsKey(key)
                    || string.Compare(queries[key], QueryStringConstraints[key].ToString(), true) != 0)
                {
                    return false;
                }
            }

            return base.Match(request, route, parameterName, values, routeDirection);
        }
开发者ID:bigred8982,项目名称:Swashbuckle.OData,代码行数:28,代码来源:ODataVersionRouteConstraint.cs

示例5: Match

        /// <inheritdoc />
        public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary<string, object> values, HttpRouteDirection routeDirection)
        {
            if (parameterName == null)
            {
                throw Error.ArgumentNull("parameterName");
            }

            if (values == null)
            {
                throw Error.ArgumentNull("values");
            }

            object value;
            if (values.TryGetValue(parameterName, out value) && value != null)
            {
                string valueString = Convert.ToString(value, CultureInfo.InvariantCulture);
                int length = valueString.Length;
                if (Length.HasValue)
                {
                    return length == Length.Value;
                }
                else
                {
                    return length >= MinLength.Value && length <= MaxLength.Value;
                }
            }
            return false;
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:29,代码来源:LengthHttpRouteConstraint.cs

示例6: Match

        /// <inheritdoc />
        public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary<string, object> values, HttpRouteDirection routeDirection)
        {
            if (parameterName == null)
            {
                throw Error.ArgumentNull("parameterName");
            }

            if (values == null)
            {
                throw Error.ArgumentNull("values");
            }

            object value;
            if (values.TryGetValue(parameterName, out value) && value != null)
            {
                if (value is long)
                {
                    return true;
                }

                long result;
                string valueString = Convert.ToString(value, CultureInfo.InvariantCulture);
                return Int64.TryParse(valueString, NumberStyles.Integer, CultureInfo.InvariantCulture, out result);
            }
            return false;
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:27,代码来源:LongHttpRouteConstraint.cs

示例7: Match

 public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName,
     IDictionary<string, object> values, HttpRouteDirection routeDirection)
 {
     var versionFinder = new VersionFinder();
     var version = versionFinder.GetVersionFromRequest(request);
     return _version == version;
 }
开发者ID:diouf,项目名称:apress-recipes-webapi,代码行数:7,代码来源:VersionConstraint.cs

示例8: Match

        /// <inheritdoc />
        public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary<string, object> values, HttpRouteDirection routeDirection)
        {
            if (route == null)
            {
                throw Error.ArgumentNull("route");
            }

            if (parameterName == null)
            {
                throw Error.ArgumentNull("parameterName");
            }

            if (values == null)
            {
                throw Error.ArgumentNull("values");
            }

            // If the parameter is optional and has no value, then pass the constraint
            object defaultValue;
            if (route.Defaults.TryGetValue(parameterName, out defaultValue) && defaultValue == RouteParameter.Optional)
            {
                object value;
                if (values.TryGetValue(parameterName, out value) && value == RouteParameter.Optional)
                {
                    return true;
                }
            }

            return InnerConstraint.Match(request, route, parameterName, values, routeDirection);
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:31,代码来源:OptionalHttpRouteConstraint.cs

示例9: Match

        public bool Match(HttpRequestMessage request,
                          IHttpRoute route,
                          string segmentPrefix,
                          IDictionary<string, object> values,
                          HttpRouteDirection routeDirection)
        {
            if (segmentPrefix == null)
            {
                throw new ArgumentNullException("segmentPrefix");
            }

            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            object value;
            if (values.TryGetValue(segmentPrefix, out value))
            {
                string valueString = value as string;
                return valueString != null
                       && (valueString.StartsWith(segmentPrefix + ";", StringComparison.OrdinalIgnoreCase)
                           || String.Equals(valueString, segmentPrefix, StringComparison.OrdinalIgnoreCase));
            }
            return false;
        }
开发者ID:andreychizhov,项目名称:microsoft-aspnet-samples,代码行数:26,代码来源:SegmentPrefixConstraint.cs

示例10: Match

        public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary<string, object> values, HttpRouteDirection routeDirection)
        {
            object rawValue;

             if (!values.TryGetValue(parameterName, out rawValue)
            || rawValue == null) {

            return true;
             }

             if (this.ParameterType.IsInstanceOfType(rawValue)) {
            return true;
             }

             string attemptedValue = Convert.ToString(rawValue, CultureInfo.InvariantCulture);

             if (attemptedValue.Length == 0) {
            return true;
             }

             object parsedVal;

             if (!TryParse(request, parameterName, rawValue, attemptedValue, CultureInfo.InvariantCulture, out parsedVal)) {
            return false;
             }

             if (routeDirection == HttpRouteDirection.UriResolution) {
            values[parameterName] = parsedVal;
             }

             return true;
        }
开发者ID:brettveenstra,项目名称:MvcCodeRouting,代码行数:32,代码来源:TypeAwareRouteConstraint.cs

示例11: Match

        /// <inheritdoc />
        public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName,
            IDictionary<string, object> values, HttpRouteDirection routeDirection)
        {
            // The match behaviour depends on value of IsRelaxedMatch.
            // If users select using relaxed match logic, the header contains both V3 (or before) and V4 style version
            // will be regarded as valid. While under non-relaxed match logic, both version headers presented will be
            // regarded as invalid. The behavior for other situations are the same. When non version headers present,
            // assume using MaxVersion.

            if (request == null)
            {
                throw Error.ArgumentNull("request");
            }

            if (routeDirection == HttpRouteDirection.UriGeneration)
            {
                return true;
            }

            if (!ValidateVersionHeaders(request))
            {
                return false;
            }

            ODataVersion? requestVersion = GetVersion(request);
            return requestVersion.HasValue && requestVersion.Value >= MinVersion && requestVersion.Value <= MaxVersion;
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:28,代码来源:ODataVersionConstraint.cs

示例12: Match

 public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName,
     IDictionary<string, object> values, HttpRouteDirection routeDirection)
 {
     if (values == null)
     {
         return true;
     }
     if (!values.ContainsKey(parameterName) || !values.ContainsKey(Id))
     {
         return true;
     }
     string action = values[parameterName].ToString().ToLower();
     if (string.IsNullOrEmpty(action))
     {
         values[parameterName] = request.Method.ToString();
     }
     else if (string.IsNullOrEmpty(values[Id].ToString()))
     {
         bool isAction = _array.All(item => action.StartsWith(item.ToLower()));
         if (isAction)
         {
             return true;
         }
         //values[Id] = values[parameterName];
         //values[parameterName] = request.Method.ToString();
     }
     return true;
 }
开发者ID:liumeifu,项目名称:OSky,代码行数:28,代码来源:StartsWithConstraint.cs

示例13: Match

 public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary<string, object> values,
     HttpRouteDirection routeDirection)
 {
     return request.Headers.UserAgent
         .Where(ua => ua.Product != null)
         .Where(ua => ua.Product.Name != null)
         .Any(ua => ua.Product.Name.IndexOf("NuGet", StringComparison.InvariantCultureIgnoreCase) != -1);
 }
开发者ID:Pliner,项目名称:TinyFeed,代码行数:8,代码来源:NuGetUserAgentConstraint.cs

示例14: Match

 public bool Match(HttpRequestMessage request,
     IHttpRoute route,
     string parameterName,
     IDictionary<string, object> values,
     HttpRouteDirection routeDirection)
 {
     return request.Method == Method;
 }
开发者ID:gabrielsimas,项目名称:ES-and-DDD,代码行数:8,代码来源:MethodConstraint.cs

示例15: Match

 public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary<string, object> values, HttpRouteDirection routeDirection)
 {
     object culture;
     if (values.TryGetValue(parameterName, out culture))
     {
         return allCultures.Any(c => string.Compare(c, culture.ToString(), true) == 0);
     }
     return false;
 }
开发者ID:chenboyi081,项目名称:asp-net-web-api-2-samples,代码行数:9,代码来源:CultureHttpRouteConstraint.cs


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