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

C# RouteDirection类代码示例

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

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



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

示例1: Match

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            //if this is an articulate root path, then we cannot match!

            //determine if it's for a particular domain
            UrlNames urlNames;
            if (_urlNames.Count == 1)
            {
                urlNames = _urlNames.FirstOrDefault();
            }
            else
            {
                urlNames = httpContext.Request.Url == null
                    ? _urlNames.FirstOrDefault()  //cannot be determined
                    : httpContext.Request.Url.Host.InvariantEquals("localhost") && !UmbracoConfig.For.UmbracoSettings().RequestHandler.UseDomainPrefixes
                        ? _urlNames.FirstOrDefault(x => x.Host == string.Empty)
                        : _urlNames.FirstOrDefault(x => x.Host.InvariantEquals(httpContext.Request.Url.Host));
            }

            if (urlNames == null) return false;

            var currentAction = values[parameterName].ToString();

            return currentAction.InvariantEquals(urlNames.TagsUrlName) || currentAction.InvariantEquals(urlNames.CategoryUrlName);
        }
开发者ID:ClaytonWang,项目名称:Articulate,代码行数:25,代码来源:TagsOrCategoryPathRouteConstraint.cs


示例2: Match

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            if (httpContext == null || !httpContext.Request.IsLocal )
                return false;

            return true;
        }
开发者ID:pmason127,项目名称:AmphiprionCMS,代码行数:7,代码来源:ServerAccessOnlyRouteConstraint.cs


示例3: Match

        //private string requiredSiteFolder;

        //public SiteFolderRouteConstraint(string folderParam)
        //{
        //    requiredSiteFolder = folderParam;
        //}

        public bool Match(
            HttpContext httpContext,
            IRouter route,
            string parameterName,
            IDictionary<string,object> values,
            RouteDirection routeDirection)
        {
            string requestFolder = RequestSiteResolver.GetFirstFolderSegment(httpContext.Request.Path);
            //return string.Equals(requiredSiteFolder, requestFolder, StringComparison.CurrentCultureIgnoreCase);
            ISiteResolver siteResolver = httpContext.ApplicationServices.GetService<ISiteResolver>();
            if(siteResolver != null)
            {
                try
                {
                    // exceptions expected here until db install scripts have run or if db connection error
                    ISiteSettings site = siteResolver.Resolve();
                    if ((site != null) && (site.SiteFolderName == requestFolder)) { return true; }
                }
                catch
                {
                    // do we need to log this?
                }

            }

            return false;
        }
开发者ID:ludev,项目名称:cloudscribe,代码行数:34,代码来源:SiteFolderRouteConstraint.cs


示例4: Match

        public bool Match(HttpContext httpContext, IRouter route, string routeKey, IDictionary<string, object> values, RouteDirection routeDirection)
        {
            var context = httpContext.ApplicationServices.GetService<IPantherContext>();
            var url = "/";


            if (context == null)
                return false;

            //if (values.ContainsKey("culture") && !CheckCulture(values["culture"].ToString()))
            //    return false;
           if(values.ContainsKey("url") && values["url"] != null)
                url = values["url"].ToString();

            var canHandle = context.CanHandleUrl(context.Path);

            if (!canHandle)
                return false;

            if (!string.IsNullOrEmpty(context.Current.Controller))
                values["controller"] = context.Current.Controller;

            if (!string.IsNullOrEmpty(context.Current.Action))
                values["action"] = context.Current.Action;

            if (!string.IsNullOrEmpty(context.Current.Route))
                context.Router.AddVirtualRouteValues(context.Current.Route, context.VirtualPath, values);

            values["context"] = context;

            return context.Current != null;
        }
开发者ID:freemsly,项目名称:CMS,代码行数:32,代码来源:HostConstraint.cs


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


示例6: Match

        protected override bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            switch (routeDirection)
            {
                case RouteDirection.IncomingRequest:
                    foreach (var method in AllowedMethods)
                    {
                        if (String.Equals(method, httpContext.Request.HttpMethod, StringComparison.OrdinalIgnoreCase))
                            return true;

                        if (httpContext.Request.Unvalidated().Form == null)
                            continue;

                        var overridden = httpContext.Request.Unvalidated().Form["_method"] ?? httpContext.Request.Unvalidated().Form["X-HTTP-Method-Override"];
                        if (String.Equals(method, overridden, StringComparison.OrdinalIgnoreCase))
                        {
                            return true;
                        }

                    }
                    break;
            }

            return base.Match(httpContext, route, parameterName, values, routeDirection);
        }
开发者ID:pdeffendol,项目名称:restful-routing,代码行数:25,代码来源:RestfulHttpMethodConstraint.cs


示例7: Match

        public bool Match([NotNull] HttpContext httpContext,
                          [NotNull] IRouter route,
                          [NotNull] string routeKey,
                          [NotNull] IDictionary<string, object> values,
                          RouteDirection routeDirection)
        {
            object value;
            if (values.TryGetValue(routeKey, out value))
            {
                var valueAsString = value as string;

                if (valueAsString != null)
                {
                    var allValues = GetAndCacheAllMatchingValues(routeKey, httpContext);
                    var match = allValues.Any(existingRouteValue =>
                                                existingRouteValue.Equals(
                                                                    valueAsString,
                                                                    StringComparison.OrdinalIgnoreCase));

                    return match;
                }
            }

            return false;
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:25,代码来源:KnownRouteValueConstraint.cs


示例8: Match

 public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
 {
     if (RequireAnonymous)
         return !httpContext.Request.IsAuthenticated;
     else
         return httpContext.Request.IsAuthenticated;
 }
开发者ID:zaLTys,项目名称:osfi,代码行数:7,代码来源:AuthenticatedConstraint.cs


示例9: IsMatch

        protected override bool IsMatch(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            if (routeDirection == RouteDirection.UrlGeneration)
            {
                return true;
            }

            if (!base.IsMatch(httpContext, route, parameterName, values, routeDirection))
            {
                return false;
            }

            //First check that language matches regex pattern
            object parameterValue; 
            values.TryGetValue(parameterName, out parameterValue);
            var parameterValueString = Convert.ToString(parameterValue, CultureInfo.InvariantCulture);
            var constraintsRegEx = string.Format("^({0})$", Constants.LanguageRegex);
            if (!Regex.IsMatch(parameterValueString, constraintsRegEx, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Compiled))
            {
                return false;
            }

            try
            {
                var culture = CultureInfo.CreateSpecificCulture(parameterValueString);
                //If culture is created then it is correct
            }
            catch
            {
                //Language is not valid
                return false;
            }

            return true;
        }
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:35,代码来源:LanguageRouteConstraint.cs


示例10: Match

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            var sid = values["id"];
            //Check sid exist in Student Table!

            return true; //
        }
开发者ID:aliab,项目名称:MVC-class,代码行数:7,代码来源:RouteConfig.cs


示例11: Match

		protected virtual bool Match (HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
		{
			if (httpContext == null)
				throw new ArgumentNullException ("httpContext");
			if (route == null)
				throw new ArgumentNullException ("route");
			if (parameterName == null)
				throw new ArgumentNullException ("parameterName");
			if (values == null)
				throw new ArgumentNullException ("values");

			switch (routeDirection) {
			case RouteDirection.IncomingRequest:
				// LAMESPEC: .NET allows case-insensitive comparison, which violates RFC 2616
				return AllowedMethods.Contains (httpContext.Request.HttpMethod);

			case RouteDirection.UrlGeneration:
				// See: aspnetwebstack's WebAPI equivalent for details.
				object method;

				if (!values.TryGetValue (parameterName, out method))
					return true;

				// LAMESPEC: .NET allows case-insensitive comparison, which violates RFC 2616
				return AllowedMethods.Contains (Convert.ToString (method));

			default:
				throw new ArgumentException ("Invalid routeDirection: " + routeDirection);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:30,代码来源:HttpMethodConstraint.cs


示例12: Match

 public bool Match(
     HttpContextBase httpContext,
     Route route,
     string parameterName,
     RouteValueDictionary values,
     RouteDirection routeDirection) =>
         Match(parameterName, values);
开发者ID:KimberlyPhan,项目名称:Its.Cqrs,代码行数:7,代码来源:GuidConstraint.cs


示例13: Match

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
#endif
        {
            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 double)
                {
                    return true;
                }

                double result;
                string valueString = Convert.ToString(value, CultureInfo.InvariantCulture);
                return Double.TryParse(valueString, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out result);
            }
            return false;
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:27,代码来源:DoubleRouteConstraint.cs


示例14: Match

        protected override bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            switch (routeDirection)
            {
                case RouteDirection.IncomingRequest:
                    foreach (var method in AllowedMethods)
                    {
                        if (String.Equals(method, httpContext.Request.HttpMethod, StringComparison.OrdinalIgnoreCase))
                            return true;

                        // fixes issues #62 and #63
                        NameValueCollection form;
                        try {
                            // first try to get the unvalidated form first
                            form = httpContext.Request.Unvalidated().Form;
                        }
                        catch (Exception e) {
                            form = httpContext.Request.Form;
                        }

                        if (form == null)
                            continue;

                        var overridden = form["X-HTTP-Method-Override"];
                        if (String.Equals(method, overridden, StringComparison.OrdinalIgnoreCase))
                        {
                            return true;
                        }

                    }
                    break;
            }

            return base.Match(httpContext, route, parameterName, values, routeDirection);
        }
开发者ID:radischevo,项目名称:restful-routing,代码行数:35,代码来源:RestfulHttpMethodConstraint.cs


示例15: Match

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
#endif
        {
            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 bool)
                {
                    return true;
                }

                bool result;
                string valueString = Convert.ToString(value, CultureInfo.InvariantCulture);
                return Boolean.TryParse(valueString, out result);
            }
            return false;
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:27,代码来源:BoolRouteConstraint.cs


示例16: Match

 protected override bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
 {
     var methodOverride = httpContext.Request.Unvalidated().Form["X-HTTP-Method-Override"];
     if (methodOverride == null) return base.Match(httpContext, route, parameterName, values, routeDirection);
     return AllowedMethods.Any(m => string.Equals(m, httpContext.Request.HttpMethod, StringComparison.OrdinalIgnoreCase))
         && AllowedMethods.Any(m => string.Equals(m, methodOverride, StringComparison.OrdinalIgnoreCase));
 }
开发者ID:saibalghosh,项目名称:UCosmic,代码行数:7,代码来源:HttpMethodOverrideConstraint.cs


示例17: Match

 public bool Match(System.Web.HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
 {
     object val;
     values.TryGetValue(parameterName, out val);
     string input = Convert.ToString(val, CultureInfo.InvariantCulture);
     return regex.IsMatch(input);
 }
开发者ID:nuhusky,项目名称:gizmo-helpers,代码行数:7,代码来源:RegexConstraint.cs


示例18:

 bool IRouteConstraint.Match(System.Web.HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
 {
     if (!values.ContainsKey(parameterName))
         return false;
     var parameterValue = values[parameterName];
     return parameterValue != null && Enum.GetNames(EnumType).Contains(parameterValue.ToString(), StringComparer.OrdinalIgnoreCase);
 }
开发者ID:rupertbates,项目名称:GuardianReviewsAzure,代码行数:7,代码来源:UrlEnumMatchConstraint.cs


示例19: Match

 public bool Match(HttpContextBase httpContext, Route route, string parameterName, 
                   RouteValueDictionary values, RouteDirection routeDirection)
 {
     bool result = httpContext.Request.UserAgent != null &&
         httpContext.Request.UserAgent.Contains(requiredUserAgent);
     return result;
 }
开发者ID:akhuang,项目名称:Books-SourceCode,代码行数:7,代码来源:UserAgentConstraint.cs


示例20: UpdateDirection

		private void UpdateDirection(RouteDirection direction)
		{
			if (direction == null)
			{
				LayoutRoot.Visibility = Visibility.Collapsed;
				return;
			}
			LayoutRoot.Visibility = Visibility.Visible;
			LayoutRoot.DataContext = direction;
			var d = direction.GetLength(LinearUnits.Miles);
			if (d == 0)
				distance.Text = "";
			else if (d >= .25)
				distance.Text = d.ToString("0.0 mi");
			else
			{
				d = direction.GetLength(LinearUnits.Yards);
				distance.Text = d.ToString("0 yd");
			}
			if (direction.Time.TotalHours >= 1)
				time.Text = direction.Time.ToString("hh\\:mm");
			else if (direction.Time.TotalMinutes > 1)
				time.Text = direction.Time.ToString("mm\\:ss");
			else if (direction.Time.TotalSeconds > 0)
				time.Text = direction.Time.ToString("ss") + " sec";
			else
				time.Text = "";
		}
开发者ID:jcscogis,项目名称:arcgis-runtime-demos-dotnet,代码行数:28,代码来源:RouteDirectionView.xaml.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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