Beispiel #1
0
        private bool CalculateRoute(RoutePath path, string httpMethod, RouteBuilder route, RouteNode node)
        {
            using (path.Pin())
                using (var pin = route.Pin())
                {
                    if (node.Part.AcceptPath(path, httpMethod))
                    {
                        route.Add(node.Part);

                        if (node.Children.Any())
                        {
                            foreach (var child in node.Children)
                            {
                                if (CalculateRoute(path, httpMethod, route, child))
                                {
                                    pin.Accept();
                                    return(true);
                                }
                            }
                        }
                        else if (!path.Any())
                        {
                            pin.Accept();
                            return(true);
                        }
                    }
                    return(false);
                }
        }
Beispiel #2
0
 private bool CalculateRoute(RoutePath path, string httpMethod, RouteBuilder route, RouteNode node)
 {
     using (path.Pin())
     using (var pin = route.Pin())
     {
         if (node.Part.AcceptPath(path, httpMethod))
         {
             route.Add(node.Part);
             
             if (node.Children.Any())
             {
                 foreach (var child in node.Children)
                 {
                     if (CalculateRoute(path, httpMethod, route, child))
                     {
                         pin.Accept();
                         return true;
                     }
                 }                    
             }
             else if (!path.Any())
             {
                 pin.Accept();
                 return true;
             }
         }
         return false;
     }
 }