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


C# RouteDirection类代码示例

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


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


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