示例#1
0
        private static NodeQuery Parse(string query, SchemaRoot schema)
        {
            if (RepositoryConfiguration.BackwardCompatibilityXmlNamespaces)
            {
                query = query.Replace(NodeQuery.XmlNamespaceOld, NodeQuery.XmlNamespace);
            }

            query = DateTimeParser.GetDateTimeModifiedQuery(query);
            query = ReplaceJScriptTags(query);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(query);

            NodeQueryTemplateReplacer.ReplaceTemplates(doc, TemplateResolvers);

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("x", NodeQuery.XmlNamespace);

            CheckValidation(doc);

            //-- Parse root chain
            var rootChain     = doc.DocumentElement.SelectSingleNode("x:*[1]", nsmgr);
            var rootChainType = rootChain.LocalName == "And" ? ChainOperator.And : ChainOperator.Or;

            NodeQuery nodeQuery = new NodeQuery(rootChainType);

            //-- Parse expression tree
            foreach (XmlNode node in rootChain.SelectNodes("x:*", nsmgr))
            {
                nodeQuery.Add(ParseExpression(node, nsmgr, schema));
            }

            //-- Parse orders
            foreach (XmlNode node in doc.DocumentElement.SelectNodes("x:Orders/x:Order", nsmgr))
            {
                nodeQuery.Orders.Add(ParseOrder(node, nsmgr, schema));
            }

            //-- Parse page
            XmlNode pageNode = doc.DocumentElement.SelectSingleNode("x:Page", nsmgr);

            if (pageNode != null)
            {
                //<Page startIndex="987" pageSize="123" />
                XmlAttribute attr = pageNode.Attributes["startIndex"];
                if (attr != null)
                {
                    nodeQuery.StartIndex = Convert.ToInt32(attr.Value, CultureInfo.InvariantCulture);
                }
                attr = pageNode.Attributes["pageSize"];
                if (attr != null)
                {
                    nodeQuery.PageSize = Convert.ToInt32(attr.Value, CultureInfo.InvariantCulture);
                }
            }
            //-- Parse top
            XmlNode topNode = doc.DocumentElement.SelectSingleNode("x:Top", nsmgr);

            if (topNode != null)
            {
                //<Top>5</Top>
                nodeQuery.Top = Convert.ToInt32(topNode.InnerText, CultureInfo.InvariantCulture);
            }

            return(nodeQuery);
        }
示例#2
0
 public IEnumerable <int> Execute(NodeQuery nodeQuery)
 {
     throw new NotSupportedException();
 }