static ParsedQueryNode Traverse(ParsedQueryNode node, ParsedQueryNodeVisitorLookup visitor, ParsedQueryNode parent) { if (node == null) return null; if (node.GetType() == typeof (ParsedQuery)) { var query = node.As<ParsedQuery>(); node = new ParsedQuery(query.Fields.Select(n => Traverse(n, visitor, node)).ToArray()); } if (node.GetType() == typeof (ParsedField)) { var field = node.As<ParsedField>(); node = new ParsedField( field.Value, field.Alias, field.Parameters.Select(n => Traverse(n, visitor, node)).ToArray(), field.Fields.Select(n => Traverse(n, visitor, node)).ToArray()); } if (node.GetType() == typeof (ParsedArgument)) { var arg = node.As<ParsedArgument>(); node = new ParsedArgument(arg.Name, Traverse(arg.Value, visitor, node)); } return visitor.Lookup(node.GetType()).Visit(node, parent); }
public ParsedField(string value, string @alias, ParsedQueryNode[] parameters, ParsedQueryNode[] fields) { Value = value; Alias = alias; Parameters = parameters; Fields = fields; }
public ParsedQuery(ParsedQueryNode[] fields) { Fields = fields; }
public static ParsedQueryNode Traverse(ParsedQueryNode node, ParsedQueryNodeVisitorLookup visitor) { return Traverse(node, visitor, null); }
public ParsedQueryNode Visit(ParsedQueryNode node, ParsedQueryNode parent) { return node; }
public ParsedQueryNode Visit(ParsedQueryNode node, ParsedQueryNode parent) { var field = node.As<ParsedField>(); schemaCursor.MoveToChild(field.Name); queryTreeCursor.Current = queryTreeCursor.Current.Branch(schemaCursor.Current) }
public ParsedArgument(string name, ParsedQueryNode value) { Name = name; Value = value; }