Beispiel #1
0
        protected Computed(IPropertyChangedRaisable viewModel, string name, IReadOnlyCollection <string> propertyNames, Func <IPropertyChangedRaisable, T> compute)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (propertyNames == null)
            {
                throw new ArgumentNullException(nameof(propertyNames));
            }
            if (compute == null)
            {
                throw new ArgumentNullException(nameof(compute));
            }

            this.Name          = name;
            this.viewModel     = viewModel;
            this.propertyNames = propertyNames;
            this.compute       = compute;

            this._val = computeVal();

            viewModel.PropertyChanged += OnViewModelPropertyChanged;
        }
Beispiel #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    this.compute = null;
                    if (this.viewModel != null)
                    {
                        this.viewModel.PropertyChanged -= OnViewModelPropertyChanged;
                        this.viewModel = null;
                    }
                }

                disposedValue = true;
            }
        }