Example #1
0
        private void NotifyProperties(Task task)
        {
            var propertyChanged = PropertyChanged;

            if (propertyChanged == null)
            {
                return;
            }

            if (task.IsCanceled)
            {
                propertyChanged(this, PropertyChangedEventArgsCache.Get("Status"));
                propertyChanged(this, PropertyChangedEventArgsCache.Get("IsCanceled"));
            }
            else if (task.IsFaulted)
            {
                propertyChanged(this, PropertyChangedEventArgsCache.Get("Exception"));
                propertyChanged(this, PropertyChangedEventArgsCache.Get("InnerException"));
                propertyChanged(this, PropertyChangedEventArgsCache.Get("ErrorMessage"));
                propertyChanged(this, PropertyChangedEventArgsCache.Get("Status"));
                propertyChanged(this, PropertyChangedEventArgsCache.Get("IsFaulted"));
            }
            else
            {
                propertyChanged(this, PropertyChangedEventArgsCache.Get("Result"));
                propertyChanged(this, PropertyChangedEventArgsCache.Get("Status"));
                propertyChanged(this, PropertyChangedEventArgsCache.Get("IsSuccessfullyCompleted"));
            }

            propertyChanged(this, PropertyChangedEventArgsCache.Get("IsCompleted"));
            propertyChanged(this, PropertyChangedEventArgsCache.Get("IsNotCompleted"));
        }
Example #2
0
 private void OnPropertyChanged(string propertyName)
 {
     if (_massUpdateScopeCount == 0)
     {
         PropertyChanged?.Invoke(this, PropertyChangedEventArgsCache.Get(nameof(Count)));
     }
 }
Example #3
0
        public IDisposable EnterMassUpdate()
        {
            _massUpdateScopeCount++;
            _waitingForMassUpdate = true;

            void DisposeAction()
            {
                _massUpdateScopeCount--;
                if (_massUpdateScopeCount == 0)
                {
                    _waitingForMassUpdate = false;

                    var args = GetChangeArguments();
                    if (args == null)
                    {
                        return;
                    }

                    OnCollectionChanged(args);
                    OnPropertyChanged(PropertyChangedEventArgsCache.Get(nameof(Count)));

                    _reset    = false;
                    _newItems = null;
                    _oldItems = null;
                }
            }

            return(Disposable.FromAction(DisposeAction));
        }
Example #4
0
        private bool SetValue <T>(ref T field, T value, [CallerMemberName] string propertyName = null)
        {
            if (EqualityComparer <T> .Default.Equals(field, value) == false)
            {
                field = value;
                PropertyChanged?.Invoke(this, PropertyChangedEventArgsCache.Get(propertyName));
                return(true);
            }

            return(false);
        }
Example #5
0
        private void NotifyExecuteChange(bool startingExecution)
        {
            var propChanged = PropertyChanged;

            if (startingExecution)
            {
                propChanged?.Invoke(this, PropertyChangedEventArgsCache.Get(nameof(Execution)));
            }

            propChanged?.Invoke(this, PropertyChangedEventArgsCache.Get(nameof(IsExecuting)));

            OnCanExecuteChanged();
        }