public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (string.IsNullOrEmpty(parameterName)) { throw new ArgumentNullException("parameterName"); } if (values == null) { throw new ArgumentNullException("values"); } var extractor = new AlbumRouteValueExtractor(values); int? photoItem = extractor.ExtractInt(parameterName); string slug = extractor.ExtractString(_slugParameterName); int? year = extractor.ExtractInt(_yearParameterName); if (photoItem == null || photoItem <= 0 || slug == null || year == null) { return false; } Album album = _albumService.GetAlbum(year.Value, slug); if (album == null) { return false; } return photoItem <= album.PhotoCount; }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (routeDirection == RouteDirection.UrlGeneration) { return true; } object versionValue; if (!values.TryGetValue(parameterName, out versionValue)) { return true; } if (versionValue == null || versionValue == UrlParameter.Optional) { return true; } string versionText = versionValue.ToString(); if (versionText.Length == 0) { return true; } SemanticVersion ignored; return SemanticVersion.TryParse(versionText, out ignored); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { Debug.WriteLine(httpContext.Request.HttpMethod == "GET"); return httpContext.Request.UserAgent != null && httpContext.Request.UserAgent.Contains(requiredUserAgent); }
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); }
//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; }
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) { 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; }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (httpContext == null || !httpContext.Request.IsLocal ) return false; return true; }
/// <summary> /// /// </summary> /// <param name="httpContext"></param> /// <param name="route"></param> /// <param name="parameterName"></param> /// <param name="values"></param> /// <param name="routeDirection"></param> /// <returns></returns> public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (values[parameterName].ToString().ToLower() == "rqitems") return true; else return false; }
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; }
// To only allow *supported* cultures as the first part of the route, instead of anything in the format xx or xx-xx comment the lower method // and uncomment this one, and make CultureManager.CultureIsSupported public. //public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) //{ // if (!values.ContainsKey(parameterName)) // return false; // string potentialCultureName = (string)values[parameterName]; // return CultureManager.CultureIsSupported(potentialCultureName); //} public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (!values.ContainsKey(parameterName)) return false; string potentialCultureName = (string)values[parameterName]; return CultureFormatChecker.FormattedAsCulture(potentialCultureName); }
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; }
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; }
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; }
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); }
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); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { var blogRepo = DependencyResolver.Current.GetService<IRepository<Data.Blog>>(); var httpContextService = DependencyResolver.Current.GetService<IHttpContextService>(); return DependencyResolver.Current.GetService<IRepository<Redirect>>().GetRedirectFor(httpContext.Request.Url.LocalPath.TrimStart('/'), blogRepo.GetCurrentBlog(httpContextService).Id) != null; }
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; }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (routeDirection == RouteDirection.IncomingRequest) { if (_alreadyProcessed.ContainsKey(httpContext.Request.Url.AbsolutePath)) { return _alreadyProcessed[httpContext.Request.Url.AbsolutePath]; } var pathParts = httpContext.Request.Url.AbsolutePath.Split('/').ToList(); var backOfficePart = pathParts.IndexOf(_appContext.Settings.RebelPaths.BackOfficePath); //ensure there's enough parts to match if (backOfficePart == -1 || ((pathParts.Count - 1) < backOfficePart + 2)) { _alreadyProcessed.AddOrUpdate(httpContext.Request.Url.AbsolutePath, false, (k, v) => false); return false; } //ensure were matching the correct area if (pathParts[backOfficePart + 1] != _areaName) { _alreadyProcessed.AddOrUpdate(httpContext.Request.Url.AbsolutePath, false, (k, v) => false); return false; } //+2 because the area name comes after the back office path var controller = pathParts[backOfficePart + 2]; if (_toIgnore.InvariantContains(controller)) { _alreadyProcessed.AddOrUpdate(httpContext.Request.Url.AbsolutePath, true, (k, v) => true); return true; } } return false; }
bool IRouteConstraint.Match(System.Web.HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { var Controllers = CoreConfiguration.Instance.IgnorableControllers.Split(','); var Actions = CoreConfiguration.Instance.IgnorableActions.Split(','); return !Controllers.Any(Controller => Controller == values["controller"].ToString()) && !Actions.Any(Action => Action == values["action"].ToString()); }
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 = ""; }
protected override bool IsMatch(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (!base.IsMatch(httpContext, route, parameterName, values, routeDirection)) { return false; } if (routeDirection == RouteDirection.UrlGeneration) { return true; } var encoded = values[parameterName].ToString(); var decoded = SettingsHelper.SeoDecode(encoded, SeoUrlKeywordTypes.Category, values.ContainsKey(Constants.Language) ? values[Constants.Language].ToString() : null); var childCategryId = decoded.Split(Separator.ToCharArray()).Last(); var category = CartHelper.CatalogClient.GetCategoryById(childCategryId); if (category == null) { return false; } var outline = new BrowsingOutline(CartHelper.CatalogOutlineBuilder.BuildCategoryOutline(StoreHelper.CustomerSession.CatalogId, category)); return ValidateCategoryPath(outline.ToString(), decoded); }
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)); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (RequireAnonymous) return !httpContext.Request.IsAuthenticated; else return httpContext.Request.IsAuthenticated; }
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; // }
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); } }
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; }
public bool Match( HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) => Match(parameterName, values);
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; }
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); }
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); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { return(true); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { object value; if (values.TryGetValue(routeKey, out value) && value != null) { return(validOptions.Contains(value.ToString(), StringComparer.OrdinalIgnoreCase)); } return(false); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return(IsMatch(parameterName, values)); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { int id; if (Int32.TryParse(values["Id"].ToString(), out id)) { return(true); } return(false); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return(httpContext.Request.UserAgent != null && httpContext.Request.UserAgent.Contains(requiredUserAgent)); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { string ReceivedValue = values[routeKey].ToString(); if (ReceivedValue.Contains("en-US") || ReceivedValue.Contains("ru-RU") || ReceivedValue.Contains("az-LATN")) { return(true); } else { return(false); } }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (httpContext.Request.UserAgent == null) { return(false); } return(httpContext.Request.UserAgent.Contains(this.requiredSubstring)); }
public bool Match(HttpContext?httpContext, IRouter?route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { if (httpContext == null) { return(false); } // Constraint needs to be valid when a CORS preflight request is received so that CORS middleware will run if (GrpcProtocolHelpers.IsCorsPreflightRequest(httpContext)) { return(true); } if (!HttpMethods.IsPost(httpContext.Request.Method)) { return(false); } return(CommonGrpcProtocolHelpers.IsContentType(GrpcProtocolConstants.GrpcContentType, httpContext.Request.ContentType) || CommonGrpcProtocolHelpers.IsContentType(GrpcProtocolConstants.GrpcWebContentType, httpContext.Request.ContentType) || CommonGrpcProtocolHelpers.IsContentType(GrpcProtocolConstants.GrpcWebTextContentType, httpContext.Request.ContentType)); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { if (!values.ContainsKey("lang")) { return(false); } var lang = values["lang"].ToString(); return(lang == "ee" || lang == "en" || lang == "ru"); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { return(Days.Contains(values[routeKey]?.ToString().ToLowerInvariant())); }
protected virtual new bool ProcessConstraint(System.Web.HttpContextBase httpContext, Object constraint, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return(default(bool)); }
public bool Match(System.Web.HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { string value = values[parameterName].ToString(); Guid g1; return(Guid.TryParse(value, out g1)); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { string segmentValue = values[routeKey] as string ?? ""; return(Array.IndexOf(countries, segmentValue.ToLower()) > -1); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return(String.Compare(values[parameterName].ToString(), _match, true) != 0); }
protected virtual new bool Match(System.Web.HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return(default(bool)); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (routeDirection == RouteDirection.UrlGeneration) { return(true); } object versionValue; if (!values.TryGetValue(parameterName, out versionValue)) { return(true); } if (versionValue == null || versionValue == UrlParameter.Optional) { return(true); } string versionText = versionValue.ToString(); if (versionText.Length == 0) { return(true); } SemanticVersion ignored; return(SemanticVersion.TryParse(versionText, out ignored)); }
/// <summary> /// Determines whether the URL parameter contains a valid value for this constraint. /// </summary> /// <param name="httpContext">The Http context.</param> /// <param name="route">The route to compare.</param> /// <param name="routeKey">The name of the parameter.</param> /// <param name="values">A list of parameter values.</param> /// <param name="routeDirection">The route direction.</param> /// <returns> /// True if this instance equals a specified route; otherwise, false. /// </returns> /// <remarks>This signature uses types that are AspNetCore-specific.</remarks> public virtual bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { if (httpContext == null) { throw Error.ArgumentNull("httpContext"); } if (values == null) { throw Error.ArgumentNull("values"); } if (routeDirection == RouteDirection.IncomingRequest) { ODataPath path = null; HttpRequest request = httpContext.Request; object oDataPathValue; if (values.TryGetValue(ODataRouteConstants.ODataPath, out oDataPathValue)) { string oDataPath = oDataPathValue as string; // Create request container request.CreateRequestContainer(RouteName); // Check whether the request is a POST targeted at a resource path ending in /$query if (request.IsQueryRequest(oDataPath)) { request.TransformQueryRequest(); oDataPath = oDataPath.Substring(0, oDataPath.LastIndexOf('/' + ODataRouteConstants.QuerySegment, StringComparison.OrdinalIgnoreCase)); values[ODataRouteConstants.ODataPath] = oDataPath; } // We need to call Uri.GetLeftPart(), which returns an encoded Url. // The ODL parser does not like raw values. Uri requestUri = new Uri(request.GetEncodedUrl()); string requestLeftPart = requestUri.GetLeftPart(UriPartial.Path); string queryString = request.QueryString.HasValue ? request.QueryString.ToString() : null; path = GetODataPath(oDataPath, requestLeftPart, queryString, () => request.GetRequestContainer()); } if (path != null) { // Set all the properties we need for routing, querying, formatting IODataFeature odataFeature = httpContext.ODataFeature(); odataFeature.Path = path; odataFeature.RouteName = RouteName; return(true); } // The request doesn't match this route so dispose the request container. request.DeleteRequestContainer(true); return(false); } else { // This constraint only applies to incoming request. return(true); } }
bool System.Web.Routing.IRouteConstraint.Match(System.Web.HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return(default(bool)); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { bool ret = false; int idPlanete = (int)values[parameterName]; if (_dataLayer.Select("", idPlanete).Count > 0) { ret = true; } return(ret); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { if (RouteDirection.IncomingRequest == routeDirection) { var v = values[routeKey]; if (long.TryParse(v.ToString(), out var value)) { return(true); } } return(false); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return(httpContext.Request.IsAuthenticated); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { // check nulls var isMatch = values.TryGetValue(routeKey, out var value) && value != null; if (isMatch) { httpContext.Items.Add("d", value); } return(isMatch); }
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") ? _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)); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { if (!values.ContainsKey("culture")) { return(false); } var culture = values["culture"].ToString(); return(culture == "en-US" || culture == "fr-FR"); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return(this._values.Contains(values[parameterName].ToString().ToLower())); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { if ((values.ContainsKey(CultureKey) == false) || (values[CultureKey] == null)) { return(false); } var lang = values[CultureKey].ToString(); var requestLocalizationOptions = httpContext.RequestServices.GetRequiredService <IOptions <RequestLocalizationOptions> >(); if ((requestLocalizationOptions.Value.SupportedCultures == null) || (requestLocalizationOptions.Value.SupportedCultures.Count == 0)) { try { new System.Globalization.CultureInfo(lang); return(true); } catch { return(false); } } return(requestLocalizationOptions.Value.SupportedCultures.Any(culture => culture.Name.Equals(lang, StringComparison.CurrentCultureIgnoreCase))); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { var isMatch = string.CompareOrdinal(route.Url.Trim('/'), httpContext.Request.RawUrl.Trim('/')) == 0; return(isMatch); }
public bool Match(HttpContext httpContext, IRouter route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { var tenantResolver = httpContext.RequestServices.GetRequiredService <TenantResolver>(); var tenantStore = httpContext.RequestServices.GetRequiredService <TenantStore>(); switch (routeDirection) { case RouteDirection.IncomingRequest: var tenant = tenantResolver.Resolve(); return(tenant != null && tenantResolver.Resolve().SiteContext.UrlSegmentValue .Equals(values[parameterName]?.ToString(), StringComparison.InvariantCultureIgnoreCase)); case RouteDirection.UrlGeneration: default: return(tenantStore.GetTenants().Values.FirstOrDefault(t => t.SiteContext.UrlSegmentValue.Equals(values[parameterName]?.ToString(), StringComparison.InvariantCultureIgnoreCase)) != null); } }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (string.IsNullOrEmpty(parameterName)) { throw new ArgumentNullException("parameterName"); } if (values == null) { throw new ArgumentNullException("values"); } var extractor = new AlbumRouteValueExtractor(values); string slug = extractor.ExtractString(parameterName); int?year = extractor.ExtractInt(_yearParameterName); if (slug == null || year == null) { return(false); } return(_albumService.GetAlbumSlugs(year.Value).Contains(slug)); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return(!Regex.IsMatch(values[parameterName] as string, this.Not)); }