internal PpsViewDefinition(PpsEnvironment environment, XElement xDefinition) : base(environment, xDefinition.GetAttribute("name", null)) { viewId = xDefinition.GetAttribute("view", String.Empty); if (String.IsNullOrEmpty(viewId)) { throw new ArgumentException("List viewId is missing."); } viewBaseFilter = PpsDataFilterExpression.Parse(xDefinition.GetAttribute("filter", String.Empty)); displayName = xDefinition.GetAttribute("displayName", this.Name); displayImage = xDefinition.GetAttribute("displayImage", this.Name); visibleCondition = environment.CreateChunk(xDefinition.Element(xnVisible), true); // parse the filters var priority = 0; this.filters = ( from c in xDefinition.Elements(xnFilter) select new PpsViewFilter(c, ref priority) ).OrderBy(c => c.Priority).ToArray(); // parse orders priority = 0; this.sortOrders = ( from c in xDefinition.Elements(xnOrder) select new PpsViewOrder(c, ref priority) ).OrderBy(c => c.Priority).ToArray(); } // ctor
} // func GetStringArray private async Task OpenCursorAsync(LuaTable table) { // not optional var selectExpression = table.GetOptionalValue("name", (string)null) ?? throw new ArgumentNullException("name"); // parse selector var selectorExpression = PpsDataFilterExpression.Parse(table.GetMemberValue("filter")); // parse optional columns var columns = PpsDataColumnExpression.Parse(table.GetMemberValue("columns")).ToArray(); // parse optional order var orderExpressions = PpsDataOrderExpression.Parse(table.GetMemberValue("order")).ToArray(); // try to get a list int cursorId; lock (cursors) cursorId = ++lastCursorId; var cursor = new OpenCursor(cursorId, await provider.GetListAsync(selectExpression, columns, selectorExpression, orderExpressions)); lock (cursors) cursors.Add(cursorId, cursor); // return the cursor id await PushPacketAsync(new LuaTable() { ["id"] = cursorId }); } // proc OpenCursorAsync
/// <summary>Parse string representation from ToString.</summary> /// <param name="data"></param> /// <param name="list"></param> /// <returns></returns> public static bool TryParse(string data, out PpsDataQuery list) { var arguments = HttpUtility.ParseQueryString(data, Encoding.UTF8); var viewId = arguments["v"]; if (String.IsNullOrEmpty(viewId)) { list = null; return(false); } list = new PpsDataQuery(viewId); var f = arguments["f"]; if (!String.IsNullOrEmpty(f)) { list.Filter = PpsDataFilterExpression.Parse(f); } var l = arguments["l"]; if (!String.IsNullOrEmpty(l)) { list.Columns = PpsDataColumnExpression.Parse(l).ToArray(); } var o = arguments["o"]; if (!String.IsNullOrEmpty(o)) { list.Order = PpsDataOrderExpression.Parse(o).ToArray(); } var s = arguments["s"]; if (!String.IsNullOrEmpty(s)) { list.Start = Int32.Parse(s); } var c = arguments["c"]; if (!String.IsNullOrEmpty(c)) { list.Count = Int32.Parse(c); } var a = arguments["a"]; if (!String.IsNullOrEmpty(a)) { list.AttributeSelector = a; } return(true); } // func TryParse
private void TestFilter(string expected, string filterExpression) { var f = PpsDataFilterExpression.Parse(filterExpression); var result = f.ToString(); Console.Write("Input====> "); Console.WriteLine(filterExpression); Console.Write("BaseType=> "); Console.WriteLine("{0}", f.Type); Console.Write("result===> "); Console.WriteLine(result); Console.Write("expected=> "); Console.WriteLine(expected); Assert.AreEqual(expected, result); }
private void UpdateFilterExpression() { if (filterView != null && AllowFilter) { var expr = PpsDataFilterExpression.Parse(UserFilterText); filterView.FilterExpression = expr; SetValue(isFilteredPropertyKey, expr == PpsDataFilterExpression.True); } else { SetValue(isFilteredPropertyKey, false); if (filterView != null) { filterView.FilterExpression = PpsDataFilterExpression.True; } } } // proc UpdateFilterExpression
public PpsDataQuery GetShellList(bool includeColumnAlias) { if (IsEmpty) { return(null); } else { return(new PpsDataQuery(Views) { Filter = PpsDataFilterExpression.Parse(Filter), Columns = columnInfos.Select(c => c.ToColumn(includeColumnAlias)).ToArray(), Order = ( from col in columnInfos let o = col.ToOrder() where o != null select o ).ToArray() }); } } // func GetShellList
} // proc OnApplyTemplate private void UpdateFilteredList() { if (ItemsSource == null) { return; } var expr = String.IsNullOrWhiteSpace(FilterText) ? PpsDataFilterExpression.True : PpsDataFilterExpression.Parse(FilterText); if (ItemsSource is IPpsDataRowViewFilter filterAble) { filterAble.FilterExpression = expr; SetValue(FilteredItemsSourcePropertyKey, ItemsSource); } else { SetValue(FilteredItemsSourcePropertyKey, ItemsSource); } } // proc UpdateFilteredList
public Predicate <IDataRow> CreateDataRowFilter(string filterExpr) => PpsDataFilterVisitorDataRow.CreateDataRowFilter <IDataRow>(PpsDataFilterExpression.Parse(filterExpr));
public void TestInExpr() { var f = PpsDataFilterExpression.Parse("Int64:(1 2 3 4 5)"); var p = PpsDataFilterVisitorLambda.CompileTypedFilter <Props>(f); var f2 = PpsDataFilterExpression.Parse("or(or(Int64:=1 Int64:=2 Int64:=3 Int64:=4 Int64:=2) Int64:=5)").Reduce(); }
internal PpsViewFilter(XElement x, ref int priority) { this.name = x.GetAttribute("name", String.Empty); if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("@name"); } this.displayName = x.GetAttribute("displayName", name); this.priority = priority = x.GetAttribute("priority", priority + 1); var expr = x.Value; this.filterExpression = String.IsNullOrEmpty(expr) ? new PpsDataFilterNativeExpression(name) : PpsDataFilterExpression.Parse(expr); } // ctor