Beispiel #1
0
 protected TrackingProperty(IFirePropertyChanged owner, IEnumerable <Expression <Func <object> > > enclosingProperties,
                            TProperty initialValue)
 {
     _value = initialValue;
     _owner = owner;
     _enclosingProperties = enclosingProperties.ToList();
 }
        /// <summary>
        /// Executed when the set accessor successfully completes. Raises the 
        /// <see cref="INotifyPropertyChanged.PropertyChanged"/> event.
        /// </summary>
        /// <param name="eventArgs">Event arguments with information about the 
        /// current execution context.</param>
        public override void OnSuccess(MethodExecutionEventArgs eventArgs)
        {
            implementation =
                (IFirePropertyChanged)
                ((IComposed<INotifyPropertyChanged>) eventArgs.Instance).GetImplementation(eventArgs.InstanceCredentials);

            implementation.OnPropertyChanged(propertyName); // Raises the PropertyChanged event.
        }
        /// <summary>
        /// Executed when the set accessor successfully completes. Raises the
        /// <see cref="INotifyPropertyChanged.PropertyChanged"/> event.
        /// </summary>
        /// <param name="eventArgs">Event arguments with information about the
        /// current execution context.</param>
        public override void OnSuccess(MethodExecutionEventArgs eventArgs)
        {
            implementation =
                (IFirePropertyChanged)
                ((IComposed <INotifyPropertyChanged>)eventArgs.Instance).GetImplementation(eventArgs.InstanceCredentials);

            implementation.OnPropertyChanged(propertyName); // Raises the PropertyChanged event.
        }
            /// <summary>
            /// Executed when the set accessor successfully completes. Raises the
            /// <see cref="INotifyPropertyChanged.PropertyChanged"/> event.
            /// </summary>
            /// <param name="eventArgs">Event arguments with information about the
            /// current execution context.</param>
            public override void OnSuccess(MethodExecutionEventArgs eventArgs)
            {
                // Get the implementation of INotifyPropertyChanged. We have access to it through the IComposed interface,
                // which is implemented at compile time.
                IFirePropertyChanged fireSemantic =
                    ((IProtectedInterface <IFirePropertyChanged>)eventArgs.Instance).GetInterface(eventArgs.InstanceCredentials);

                // Raises the PropertyChanged event.
                fireSemantic.FirePropertyChanged(propertyName);
            }
        public override void OnSetValue(FieldAccessEventArgs eventArgs)
        {
            IFirePropertyChanged implementation =
                (IFirePropertyChanged)
                ((IComposed <INotifyPropertyChanged>)eventArgs.Instance).GetImplementation(eventArgs.InstanceCredentials);

            //// no bubbling (performance)!
            // next optimization does not work; run unit tests
            //if (implementation.ObserversObjects.Count == 0)
            //{
            //    base.OnSetValue(eventArgs);
            //    return;
            //}

            object oldValue = eventArgs.StoredFieldValue;
            object newValue = eventArgs.ExposedFieldValue;


            // manage subscription to childobjects that are notifiable
            if (oldValue is INotifyPropertyChanged)
            {
                implementation.Unsubscribe(oldValue as INotifyPropertyChanged);
            }

            if (newValue is INotifyPropertyChanged)
            {
                implementation.Subscribe(newValue as INotifyPropertyChanged);
            }

/*
 *          base.OnSetValue(eventArgs);
 */


            var value = oldValue ?? newValue;

            if (value == null)
            {
                base.OnSetValue(eventArgs);
            }
            else
            {
                // prevent calling set values two times, call it only in the last aspect
                var valueImplements2Aspects = value is INotifyPropertyChanged && value is INotifyCollectionChanged;

                if (!valueImplements2Aspects || implementation.IsLastPropertyNotifier)
                {
                    base.OnSetValue(eventArgs);
                }
            }
        }
Beispiel #6
0
 public TrackingNonNullProperty([NotNull] TProperty initialValue, [NotNull] IFirePropertyChanged owner,
                                [NotNull] params Expression <Func <object> >[] enclosingProperties)
     : base(owner, enclosingProperties, initialValue)
 {
     ValidateNewValue(initialValue);
 }
Beispiel #7
0
 public TrackingNullableProperty([NotNull] IFirePropertyChanged owner,
                                 [NotNull] params Expression <Func <object> >[] enclosingProperties)
     : base(owner, enclosingProperties, null)
 {
 }
Beispiel #8
0
 public void Call([NotNull] IFirePropertyChanged sender, [NotNull] Expression <Func <object> > propertyExpression)
 {
     Call(sender, new PropertyChangedEventArgs(Extract.PropertyNameFrom(propertyExpression)));
 }
 public DependantProperty(IFirePropertyChanged sender, Expression <Func <object> > propertyExpression)
 {
     _sender             = sender;
     _propertyExpression = propertyExpression;
 }
 public static DependantProperty Propagate([NotNull] this IFirePropertyChanged sender,
                                           [NotNull] Expression <Func <object> > propertyExpression)
 {
     return(new DependantProperty(sender, propertyExpression));
 }