Exemplo n.º 1
0
        private static RoutingData JoinRoutingData(RoutingData prev, RoutingData next)
        {
            var newParts = new string[prev.PathParts.Length + next.PathParts.Length];

            Array.Copy(prev.PathParts, 0, newParts, 0, prev.PathParts.Length);
            Array.Copy(next.PathParts, 0, newParts, prev.PathParts.Length, next.PathParts.Length);
            return(new RoutingData(next.UserCommand, prev.Path + ":" + next.Path, newParts, next.Content, prev));
        }
Exemplo n.º 2
0
        public RoutingResult FindRoute(RoutingData routingData)
        {
            var matched = _routes
                          .Select(r => r.Match(routingData))
                          .Where(m => m.IsMatched).ToArray();

            if (matched.Length == 0)
            {
                return(RoutingResult.Mismatched);
            }
            var completed = matched.FirstOrDefault(m => m.IsCompleted);

            return(new RoutingResult(completed, matched.Where(r => !r.IsCompleted)));
        }
Exemplo n.º 3
0
 public RouterFeature(IRoute route, RoutingData routingData, Dictionary <string, string> fields)
 {
     Route       = route;
     RoutingData = routingData;
     Fields      = new ReadOnlyDictionary <string, string>(fields);
 }