public CompositePathGetter
        (
            IEnumerable <IBindingPathLink <object> > pathLinks,
            PropertyType defaultValue
        )
        {
            _pathLinks = pathLinks;

            _defaultValue = defaultValue;

            if (pathLinks.IsNullOrEmpty())
            {
                PropGetters.Add(new SimplePropGetter <object>());
                return;
            }

            IObjWithPropGetter <object> previousPropGetter = null;

            foreach (var pathLink in _pathLinks)
            {
                IObjWithPropGetter <object> propGetter = pathLink.CreateGetter();

                PropGetters.Add(propGetter);

                if (previousPropGetter != null)
                {
                    IObjWithPropGetter <object> thePreviousPropGetter = previousPropGetter;
                    previousPropGetter.PropertyChangedEvent += () =>
                    {
                        propGetter.TheObj = thePreviousPropGetter.GetPropValue();
                    };
                }

                previousPropGetter = propGetter;
            }

            previousPropGetter.PropertyChangedEvent += () =>
            {
                if (this.PropertyChangedEvent == null)
                {
                    return;
                }

                if (!LastPropGetter.HasObj)
                {
                    _cachedValue.TheValue = _defaultValue;
                }
                else
                {
                    _cachedValue.TheValue = (PropertyType)LastPropGetter.GetPropValue();
                }

                PropertyChangedEvent?.Invoke();
            };
        }
Пример #2
0
        public void Addiere(Aufgabe a)
        {
            // Aufgaben.Add(a); böse

            Aufgaben.Add(new Aufgabe
            {
                Text = a.Text,
                ID   = Aufgaben.Count
            });

            PropertyChangedEvent.Invoke(this, EventArgs.Empty);
        }
Пример #3
0
        protected virtual void OnRaisePropertyChanged <T>(string propertyName, T previousValue, T actualValue)
        {
            var action = new Action <string, T, T>((pro, pre, act) => {
                PropertyChangedEvent?.Invoke(this, new PropertyChangedEventArgs(pro));
                PropertyChanged?.Invoke(this as TNotifier, new NotifierPropertyChangedEventArgs <TNotifier>(pro, (TNotifier)(INotifier <TNotifier>) this, pre, act));
            });

            if (UseSynchronizerOnRaisePropertyChanged && Synchronizer != null)
            {
                Synchronizer.Invoke(action, propertyName, previousValue, actualValue).Wait();
            }
            else
            {
                action(propertyName, previousValue, actualValue);
            }
        }
 public void TriggerPropertyChanged()
 {
     PropertyChangedEvent?.Invoke();
 }
Пример #5
0
 protected virtual void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
 {
     PropertyChangedEvent?.Invoke(this, new PropertyChangedEventArgs(propertyName));
 }
 private void ModifyEnum(int value)
 {
     OnValueChanged.Invoke(value, path);
 }
Пример #7
0
 public void PropertyChanged()
 {
     PropertyChangedEvent?.Invoke(this, EventArgs.Empty);
 }
Пример #8
0
 protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
 {
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
     PropertyChangedEvent?.Invoke(propertyName);
 }
Пример #9
0
 protected virtual void OnPropertyChanged(string propertyName)
 {
     PropertyChangedEvent?.Invoke(this, new PropertyChangedEventArgs(propertyName));
 }