示例#1
0
        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);
        }
示例#2
0
 public ParsedField(string value, string @alias, ParsedQueryNode[] parameters, ParsedQueryNode[] fields)
 {
     Value = value;
     Alias = alias;
     Parameters = parameters;
     Fields = fields;
 }
示例#3
0
 public ParsedQuery(ParsedQueryNode[] fields)
 {
     Fields = fields;
 }
示例#4
0
 public static ParsedQueryNode Traverse(ParsedQueryNode node, ParsedQueryNodeVisitorLookup visitor)
 {
     return Traverse(node, visitor, null);
 }
示例#5
0
 public ParsedQueryNode Visit(ParsedQueryNode node, ParsedQueryNode parent)
 {
     return node;
 }
示例#6
0
 public ParsedQueryNode Visit(ParsedQueryNode node, ParsedQueryNode parent)
 {
     var field = node.As<ParsedField>();
     schemaCursor.MoveToChild(field.Name);
     queryTreeCursor.Current = queryTreeCursor.Current.Branch(schemaCursor.Current)
 }
示例#7
0
 public ParsedArgument(string name, ParsedQueryNode value)
 {
     Name = name;
     Value = value;
 }