本文整理汇总了C#中IRoute类的典型用法代码示例。如果您正苦于以下问题:C# IRoute类的具体用法?C# IRoute怎么用?C# IRoute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRoute类属于命名空间,在下文中一共展示了IRoute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RouteMatch
/// <summary>
/// Initializes a new instance of the <see cref="RouteMatch"/> class.
/// </summary>
/// <param name="success">if set to <c>true</c> [success].</param>
/// <param name="route">The route.</param>
/// <param name="parameterValues">The parameter values.</param>
/// <param name="failReason">The fail reason.</param>
private RouteMatch(bool success, IRoute route, IDictionary parameterValues, string failReason)
{
this.success = success;
this.route = route;
this.failReason = failReason;
values = new RouteValueDictionary(parameterValues);
}
示例2: MatchPath
/// <summary>
/// Given a path, attempts to match the next part of it to the current segment.
/// </summary>
/// <param name="route">The route.</param>
/// <param name="path">The path.</param>
/// <returns>
/// An object that indicates whether the path was successfully matched.
/// </returns>
public override SegmentPathMatch MatchPath(IRoute route, PathIterator path)
{
var next = path.Next();
return String.Equals(next, literal, StringComparison.InvariantCultureIgnoreCase)
? SegmentPathMatch.Successful()
: SegmentPathMatch.Failure(string.Format("Expected segment '{0}'; got '{1}'", literal, next));
}
示例3: CalculateBestPlacement
/// <summary>
/// Returns the customer that least increases the length of the given route.
/// </summary>
/// <param name="problem"></param>
/// <param name="route"></param>
/// <returns></returns>
public static TwoOptResult CalculateBestPlacement(
IProblemWeights problem,
IRoute route)
{
//int previous1 = -1;
//foreach (int customer1 in route)
//{
// if (previous1 >= 0)
// {
// int previous2 = -1;
// foreach (int customer2 in route)
// {
// if (previous1 != previous2)
// {
// // test the two opt move.
// }
// previous2 = customer2;
// }
// }
// previous1 = customer1;
//}
throw new NotImplementedException();
}
示例4: MatchPath
/// <summary>
/// Given a path, attempts to match the next part of it to the current segment.
/// </summary>
/// <param name="route">The route.</param>
/// <param name="path">The path.</param>
/// <returns>
/// An object that indicates whether the path was successfully matched.
/// </returns>
public override SegmentPathMatch MatchPath(IRoute route, PathIterator path)
{
var values = new RouteValueDictionary();
var next = path.Next();
if (next.Length == 0)
{
if (defaultValue != UrlParameter.NotSpecified)
{
values[parameterName] = defaultValue;
}
else
{
return SegmentPathMatch.Failure(string.Format("The path does not contain a segment for parameter '{0}'", parameterName));
}
}
else
{
values[parameterName] = next;
if (constraint != null && !constraint.IsValid(route, next, parameterName))
{
return SegmentPathMatch.Failure(string.Format("Segment '{0}' did not match the constraint on parameter '{1}'", next, parameterName));
}
}
return SegmentPathMatch.Successful(values);
}
示例5: Log
public void Log(IRoute route)
{
_routeLog.Add(route);
Routes = _routeLog
.OrderByDescending(r => r.End)
.ToList();
}
示例6: Show
public void Show(IRoute route, IEnumerable<IError> errors)
{
var view = route[KnownParameters.View] as UserControl;
var adornerLayer = AdornerLayer.GetAdornerLayer(view);
adornerLayer.Add(new ErrorsAdorner(view, errors));
}
示例7: Matches
public bool Matches(IRoute route, IPath path)
{
var routePath = route.Path;
if (!routePath.IsLiteral)
return false;
return routePath.LiteralPath.Equals(path.LiteralPath);
}
示例8: NancyEngineFixture
public NancyEngineFixture()
{
this.resolver = A.Fake<IRouteResolver>();
this.route = A.Fake<IRoute>();
A.CallTo(() => resolver.GetRoute(A<IRequest>.Ignored.Argument)).Returns(route);
this.engine = new NancyEngine(resolver);
}
示例9: CreateViewModel
public object CreateViewModel(IRoute route)
{
var type = GetTypeFor(route);
if (type == null)
return null;
return IoC.Get(type);
}
示例10: PathMatch
/// <summary>
/// Initializes a new instance of the <see cref="PathMatch"/> class.
/// </summary>
/// <param name="success">if set to <c>true</c> [success].</param>
/// <param name="route">The route.</param>
/// <param name="routeValues">The route values.</param>
/// <param name="leftOver">The left over.</param>
/// <param name="segmentValues">The segment values.</param>
/// <param name="failReason">The fail reason.</param>
private PathMatch(bool success, IRoute route, RouteValueDictionary routeValues, RouteValueDictionary leftOver, List<object> segmentValues, string failReason)
{
this.success = success;
this.route = route;
this.routeValues = routeValues;
this.leftOver = leftOver;
this.segmentValues = segmentValues;
this.failReason = failReason;
}
示例11: Process
public IRouteResult Process(IRoute route)
{
var listener = route[KnownParameters.Listener] as IListener;
var result = listener.Execute(route)
.AddParameter(KnownParameters.ProcessedByListener, true);
return result as IRouteResult;
}
示例12: CreateView
public object CreateView(IRoute route)
{
var type = GetTypeFor(route);
if (type == null)
return null;
return Activator.CreateInstance(type);
}
示例13: CheckParameter
private static object CheckParameter(IRoute route, ParameterInfo parameterInfo)
{
if (parameterInfo.ParameterType == typeof(int))
{
return int.Parse(route.Parameters[parameterInfo.Name]);
}
return route.Parameters[parameterInfo.Name];
}
示例14: MapParameters
private static object[] MapParameters(IRoute route, MethodInfo action)
{
var result = action
.GetParameters()
.Select(parameterInfo =>
CheckParameter(route, parameterInfo)).ToArray();
return result;
}
示例15: RouteEquals
public static bool RouteEquals(this IRoute r1, IRoute r2)
{
if (r1.Resource != r2.Resource)
return false;
if (r1.Action != r2.Action)
return false;
return true;
}