private IDictionary <string, DocumentSortOrder> BuildOrder(IHttpRequest request) { var orderMethods = ParseOrder(request); if (orderMethods != null) { var order = new Dictionary <string, DocumentSortOrder>(); foreach (var orderMethod in orderMethods) { var orderProperties = FuncOrderQuerySyntaxVisitor.CreateOrderExpression(orderMethod); if (orderProperties != null) { foreach (var orderProperty in orderProperties) { order.Add(orderProperty.Key, orderProperty.Value); } } } return(order); } return(null); }
public static IEnumerable <KeyValuePair <string, DocumentSortOrder> > CreateOrderExpression(InvocationQuerySyntaxNode node) { var visitor = new FuncOrderQuerySyntaxVisitor(); var orderProperties = visitor.Visit(node); return(orderProperties); }
private static IEnumerable <KeyValuePair <string, DocumentSortOrder> > TextScoreInvocation(FuncOrderQuerySyntaxVisitor visitor, InvocationQuerySyntaxNode node) { // textScore(property) --> p.IncludeTextScore(property) var property = (node.Arguments.Count > 0) ? node.Arguments[0].AsIdentifierName() : QuerySyntaxHelper.TextScoreMethodName; yield return(new KeyValuePair <string, DocumentSortOrder>(property, DocumentSortOrder.TextScore)); }
private static IEnumerable <KeyValuePair <string, DocumentSortOrder> > DescInvocation(FuncOrderQuerySyntaxVisitor visitor, InvocationQuerySyntaxNode node) { // desc(property1, property2, property3, ...) --> new[] { { property1, DocumentSortOrder.Desc }, { property2, DocumentSortOrder.Desc }, { property3, DocumentSortOrder.Desc }, ... } return(node.Arguments.Select(i => new KeyValuePair <string, DocumentSortOrder>(i.AsIdentifierName(), DocumentSortOrder.Desc))); }