本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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; //
}
示例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);
}
}
示例12: Match
public bool Match(
HttpContextBase httpContext,
Route route,
string parameterName,
RouteValueDictionary values,
RouteDirection routeDirection) =>
Match(parameterName, values);
示例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;
}
示例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);
}
示例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;
}