Пример #1
0
        protected virtual Task WaitCurrentNavigationsInternalAsync(IDataContext context)
        {
            var tasks = new List <Task>();

            foreach (var dynamicPresenter in _dynamicPresenters)
            {
                var awaitablePresenter = dynamicPresenter as IAwaitableDynamicViewModelPresenter;
                if (awaitablePresenter != null)
                {
                    tasks.Add(awaitablePresenter.WaitCurrentNavigationAsync(context));
                }
            }
            return(ToolkitExtensions.WhenAll(tasks.ToArray()));
        }
Пример #2
0
        protected virtual Task ValidateInstanceInternal(object instanceToValidate)
        {
            List <IValidator> list;

            if (!_instanceToValidators.TryGetValue(instanceToValidate, out list) || list.Count == 0)
            {
                return(Empty.Task);
            }
            if (list.Count == 1)
            {
                return(list[0].ValidateAsync());
            }
            return(ToolkitExtensions.WhenAll(list.ToArrayEx(validator => validator.ValidateAsync())));
        }
Пример #3
0
        protected virtual Task ValidateInternal()
        {
            var tasks = new List <Task>();

            foreach (var validators in _instanceToValidators.Values)
            {
                for (int index = 0; index < validators.Count; index++)
                {
                    tasks.Add(validators[index].ValidateAsync());
                }
            }
            if (tasks.Count == 1)
            {
                return(tasks[0]);
            }
            return(ToolkitExtensions.WhenAll(tasks.ToArrayEx()));
        }
 public Task <bool> GetCanCloseAsync()
 {
     if (Cancel)
     {
         return(MugenMvvmToolkit.Empty.FalseTask);
     }
     if (_deferrals == null)
     {
         return(MugenMvvmToolkit.Empty.TrueTask);
     }
     Task <bool>[] tasks;
     lock (_deferrals)
         tasks = _deferrals.ToArray();
     return(ToolkitExtensions.WhenAll(tasks).ContinueWith(task =>
     {
         return tasks.All(t => !t.Result);
     }, TaskContinuationOptions.ExecuteSynchronously));
 }