Пример #1
0
        public override async void CanExecuteCommand(params IJavascriptObject[] e)
        {
            var parameter = _JavascriptToCSharpConverter.GetFirstArgumentOrNull(e);
            var res       = await UiDispatcher.EvaluateAsync(() => _Command.CanExecute(parameter));

            UpdateCanExecuteValue(res);
        }
Пример #2
0
        private async void ComputeCanExecute()
        {
            var res = await UiDispatcher.EvaluateAsync(() => _Command.CanExecute);

            if (res == _CanExecute)
            {
                return;
            }

            _CanExecute = res;
            UpdateCanExecuteValue(res);
        }
Пример #3
0
        public override async void CanExecuteCommand(params IJavascriptObject[] e)
        {
            var parameter = _JavascriptToCSharpConverter.GetFirstArgument <T>(e);

            if (!parameter.Success)
            {
                Logger.Error($"Impossible to call CanExecuteCommand on command<{typeof(T)}>, no matching argument found, received:{parameter.TentativeValue} of type:{parameter.TentativeValue?.GetType()} expectedType: {typeof(T)}");
                return;
            }
            var res = await UiDispatcher.EvaluateAsync(() => _Command.CanExecute(parameter.Value));

            UpdateCanExecuteValue(res);
        }
        public async void Execute(IJavascriptObject[] arguments)
        {
            var promise  = GetPromise(arguments);
            var argument = GetArgumentValueOnJsContext(arguments);

            if (!argument.Success)
            {
                return;
            }

            try
            {
                await await UiDispatcher.EvaluateAsync(async() =>
                {
                    var res = await ExecuteOnUiThread(argument.Value);
                    _CSharpUnrootedObjectManager.RegisterInSession(res, bridge => SetResult(promise, bridge));
                });
            }
            catch (Exception exception)
            {
                SetError(promise, exception).DoNotWait();
            }
        }
Пример #5
0
 public Task <T> EvaluateOnUiContextAsync <T>(Func <T> act)
 {
     return(UiDispatcher.EvaluateAsync(act));
 }