Beispiel #1
0
        }         // 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
Beispiel #2
0
        /// <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