Пример #1
0
        private async void OnReceiveQuery(object sender, ReceiveQueryEventArgs e)
        {
            string rawContent = e.Query.Query;
            int    i          = FindColonCharIndex(rawContent);
            string command    = (i == -1) ? rawContent : rawContent.Substring(0, i);
            string content    = (i == -1) ? "" : rawContent.Substring(i + 1);

            string res = await _dispatcher.ReceiveQuery(new ReceivedQuery(command, content));

            e.Query.Reply(res);
        }
Пример #2
0
        private void OnReceivedQuery(object?sender, ReceiveQueryEventArgs e)
        {
            string content = e.Query.Query;
            int    i       = FindColonCharIndex(content);
            string command = (i == -1) ? content : content.Substring(0, i);
            string args    = (i == -1) ? "" : content.Substring(i + 1);

            var ea = new QueryReceivedEventArgs(command, args);

            App.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                ReceivedQuery?.Invoke(this, ea);
                e.Query.Reply(string.IsNullOrWhiteSpace(ea.Result) ? "" : ea.Result);
            }));
        }