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
        }         // func LuaCreateSource

        #endregion

        #region -- Load/Unload --------------------------------------------------------

        private Uri GetPaneUri(LuaTable arguments, bool throwException)
        {
            // get the basic template
            var paneFile = arguments.GetOptionalValue("Pane", String.Empty);

            return(String.IsNullOrEmpty(paneFile)
                                ? (throwException ? throw new ArgumentException("Pane is missing.") : (Uri)null)
                                : Shell.Request.CreateFullUri(paneFile)); // prepare the base
        }                                                                 // func GetPaneUri
Beispiel #3
0
            }             // func GetDataSetAsync

            public override Task <LuaTable> ExecuteAsync(LuaTable arguments)
            {
                var functionName = arguments.GetOptionalValue("name", (string)null);

                if (functionName == null)
                {
                    throw new ArgumentNullException("name", "No function definied.");
                }

                return(Task.FromResult(new LuaResult(application.CallMember(functionName, arguments))[0] as LuaTable));
            }     // func ExecuteAsync
Beispiel #4
0
        }         // func CompileLuaAction

        private DEConfigAction CompileLuaAction(string actionName, LuaTable ca)
        {
            if (actionName == null || ca == null)
            {
                return(DEConfigAction.Empty);
            }

            if (!(ca["Method"] is Delegate dlg))
            {
                return(DEConfigAction.Empty);
            }

            return(new DEConfigAction(
                       ca.GetOptionalValue <string>("Security", null),
                       ca.GetOptionalValue <string>("Description", null),
                       CompileMethodAction(actionName, dlg.Method, dlg, i => ca[i + 1]).Compile(),
                       ca.GetOptionalValue("SafeCall", true),
                       dlg.Method,
                       ca.GetOptionalValue("AutoLog", false)
                       ));
        }         // func CompileLuaAction
Beispiel #5
0
        }         // func CompileLuaAction

        private DEConfigAction CompileLuaAction(string sAction, LuaTable ca)
        {
            if (sAction == null || ca == null)
            {
                return(DEConfigAction.Empty);
            }

            var dlg = ca["Method"] as Delegate;

            if (dlg == null)
            {
                return(DEConfigAction.Empty);
            }

            return(new DEConfigAction(
                       ca.GetOptionalValue <string>("Security", null),
                       ca.GetOptionalValue <string>("Description", null),
                       CompileMethodAction(dlg.Method, dlg, i => ca[i + 1]).Compile(),
                       ca.GetOptionalValue("SafeCall", true),
                       dlg.Method
                       ));
        }         // func CompileLuaAction
Beispiel #6
0
        public string DebugEmitter(LuaTable table)
        {
            var arguments  = table.GetOptionalValue("converter", (string)null);
            var columnName = table.GetOptionalValue("columnName", (string)null);
            // create row
            var row = GetRowContent((table.GetMemberValue("row") as LuaTable) ?? throw new ArgumentNullException("row", "Row information is missing."));

            using (var session = reporting.CreateDebugReportSession())
                using (var sw = new StringWriter())
                    using (var xml = XmlWriter.Create(sw, new XmlWriterSettings()
                    {
                        NewLineHandling = NewLineHandling.Entitize, IndentChars = "  ", Async = true
                    }))
                    {
                        // emit column
                        var emitter = session.CreateColumnEmitter(arguments, columnName, row);
                        xml.WriteStartElement(emitter.ElementName);
                        emitter.WriteAsync(xml, row).AwaitTask();
                        xml.WriteEndElement();
                        xml.Flush();

                        return(sw.GetStringBuilder().ToString());
                    }
        }         // func DebugEmitter