コード例 #1
0
        public Robot Parse(IEnumerator <string> enumerator)
        {
            var position = _positionParser.Parse(enumerator.Current);

            enumerator.MoveNext();
            var route = _routeParser.Parse(enumerator.Current);

            return(Robot.From(position, route));
        }
コード例 #2
0
        public IReadOnlyList <PathMatcher> Parse(string path)
        {
            IReadOnlyList <PathMatcher> pathMatchers;

            if (!RouteParsingCache.TryGetValue(path, out pathMatchers))
            {
                RouteParsingCache[path] = pathMatchers = _innerParser.Parse(path);
            }
            return(pathMatchers);
        }
コード例 #3
0
 /// <summary>
 /// Gives the route a chance to inialize itself. This method is called when the route is registered
 /// in a route collection. It should be used for any pre-compilation, caching or validation tasks.
 /// </summary>
 public void Validate()
 {
     if (parsedRoute == null)
     {
         parsedRoute = parser.Parse(this, pathSpecification, defaults, constraints);
         var result = validator.Validate(parsedRoute);
         if (!result.Success)
         {
             throw new InvalidRouteException(
                       this,
                       result,
                       string.Format("The route with specification '{0}' is invalid: {1}", pathSpecification, string.Join("", result.Errors.Select(x => Environment.NewLine + " - " + x).ToArray()))
                       );
         }
     }
 }
コード例 #4
0
 protected override void Because()
 {
     _exception = Catch.Exception(() => _route = _routeParser.Parse(_routeText));
 }
コード例 #5
0
 public static void Add(this RouteCollection routes, FalcorMethod method, string path, RouteHandler handler) =>
 Add(routes, method, RouteParser.Parse(path), handler);