public Enumerator(DefaultChannel channel, CancellationToken cancellationToken, IReadOutput output) { _channel = channel ?? throw new ArgumentNullException(nameof(channel)); _cancellationToken = cancellationToken; _output = output; _current = _channel._graph.Root; }
public DuplicateRouteException(IRouteNode parentNode, IRouteNode duplicateNode, IRouteNode duplicatedNode) : base("Cannot add node " + duplicateNode + " to parent node " + parentNode + ". Child collides with existing node " + duplicatedNode) { ParentNode = parentNode; DuplicateNode = duplicateNode; DuplicatedNode = duplicatedNode; }
public DuplicateRouteException(IRouteNode parentNode, IRouteNode duplicateNode, IRouteNode duplicatedNode) : base("Cannot add node " + duplicateNode + " to parent node " + parentNode + ". Child collides with existing node " + duplicatedNode) { ParentNode = parentNode; DuplicateNode = duplicateNode; DuplicatedNode = duplicatedNode; }
public IRouteNode FindDuplicate(IRouteNode parent) { var duplicate = Part.FindDuplicate(parent.Children.Select(x => x.Part)); if (duplicate != null) { return(parent.Children.Single(x => x.Part == duplicate)); } return(null); }
public ValueTask <bool> MoveNextAsync() { _current = NextNode(_current); if (_current == null || _cancellationToken.IsCancellationRequested) { Current = null; return(new ValueTask <bool>(false)); } Current = _channel.CreateProcessor(_current.Statement); return(new ValueTask <bool>(true)); }
private RouteNode AddNode(IRouteNode parent, RouteNode child) { // var duplicate = child.FindDuplicate(parent); // if (duplicate != null) // { // child.FindDuplicate(parent); // throw new DuplicateRouteException(parent, child, duplicate); // } if (child.Part is RouteLiteral) { var routeLiteral = (RouteLiteral)child.Part; if (!routeLiteral.IsTerminal) { var commonChild = parent.Children.SingleOrDefault(x => x.Part is RouteLiteral && ((RouteLiteral)x.Part).Literal == routeLiteral.Literal && !((RouteLiteral)x.Part).IsTerminal); if (commonChild != null) { return(commonChild); } } } if (child.Part is RouteVariable) { var routeVariable = (RouteVariable)child.Part; if (!routeVariable.IsTerminal) { var commonChild = parent.Children.SingleOrDefault(x => x.Part is RouteVariable && !((RouteVariable)x.Part).IsTerminal); if (commonChild != null) { return(commonChild); } } } if (child.Part.RouteData.ContainsKey(Routes.RouteData.RequiredHttpMethodKey) || child.Part is RouteLiteral) { parent.Children.Insert(0, child); } else { parent.Children.Add(child); } return(child); }
private IRouteNode NextNode(IRouteNode current) { if (_isFirst) { _isFirst = false; return(_channel._graph.Root); } switch (current.Statement.Statement) { case Statement.Filter: if (_output.Output is bool filter && filter) { goto default; } return(null); default: return(_current.Children.FirstOrDefault()); } }
public IRouteNode FindDuplicate(IRouteNode parent) { return(null); }
public DefaultRouteGraph(IRouteNode root) { Root = root ?? throw new ArgumentNullException(nameof(root)); }
public IRouteNode FindDuplicate(IRouteNode parent) { return null; }
private RouteNode AddNode(IRouteNode parent, RouteNode child) { // var duplicate = child.FindDuplicate(parent); // if (duplicate != null) // { // child.FindDuplicate(parent); // throw new DuplicateRouteException(parent, child, duplicate); // } if (child.Part is RouteLiteral) { var routeLiteral = (RouteLiteral)child.Part; if (!routeLiteral.IsTerminal) { var commonChild = parent.Children.SingleOrDefault(x => x.Part is RouteLiteral && ((RouteLiteral)x.Part).Literal == routeLiteral.Literal && !((RouteLiteral)x.Part).IsTerminal); if (commonChild != null) { return commonChild; } } } if (child.Part is RouteVariable) { var routeVariable = (RouteVariable)child.Part; if (!routeVariable.IsTerminal) { var commonChild = parent.Children.SingleOrDefault(x => x.Part is RouteVariable && !((RouteVariable)x.Part).IsTerminal); if (commonChild != null) { return commonChild; } } } if (child.Part.RouteData.ContainsKey(Routes.RouteData.RequiredHttpMethodKey) || child.Part is RouteLiteral) parent.Children.Insert(0, child); else parent.Children.Add(child); return child; }
public void Add(IRouteNode children) => _children.Add(children);