GetValue() private method

private GetValue ( DependencyProperty dp ) : object
dp System.Windows.DependencyProperty
return object
Ejemplo n.º 1
0
        /// <summary>
        /// Invalidate the given child expression.
        /// </summary>
        internal override void InvalidateChild(BindingExpressionBase bindingExpression)
        {
            // Prevent re-entrancy, because ChooseActiveBindingExpression() may
            // activate/deactivate a BindingExpression that indirectly calls this again.
            if (_isInInvalidateBinding)
            {
                return;
            }
            _isInInvalidateBinding = true;

            int index = MutableBindingExpressions.IndexOf(bindingExpression);
            DependencyObject target = TargetElement;

            if (target != null && 0 <= index && index < AttentiveBindingExpressions)
            {
                // Optimization: only look for new ActiveBindingExpression when necessary:
                // 1. it is a higher priority BindingExpression (or there's no ActiveBindingExpression), or
                // 2. the existing ActiveBindingExpression is broken
                if (index != _activeIndex ||
                    (bindingExpression.StatusInternal != BindingStatusInternal.Active && !bindingExpression.UsingFallbackValue))
                {
                    ChooseActiveBindingExpression(target);
                }

                // update the value
                UsingFallbackValue = false;
                BindingExpressionBase bindExpr = ActiveBindingExpression;
                object newValue = (bindExpr != null) ? bindExpr.GetValue(target, TargetProperty) : UseFallbackValue();
                ChangeValue(newValue, true);

                if (TraceData.IsExtendedTraceEnabled(this, TraceDataLevel.Transfer))
                {
                    TraceData.TraceAndNotifyWithNoParameters(TraceEventType.Warning,
                                                             TraceData.PriorityTransfer(
                                                                 TraceData.Identify(this),
                                                                 TraceData.Identify(newValue),
                                                                 _activeIndex,
                                                                 TraceData.Identify(bindExpr)),
                                                             this);
                }

                // don't invalidate during Attach.  The property engine does it
                // already, and it would interfere with the on-demand activation
                // of style-defined BindingExpressions.
                if (!IsAttaching)
                {
                    // recompute expression
                    target.InvalidateProperty(TargetProperty);
                }
            }

            _isInInvalidateBinding = false;
        }
        // Token: 0x06001C74 RID: 7284 RVA: 0x00085D1C File Offset: 0x00083F1C
        internal override void InvalidateChild(BindingExpressionBase bindingExpression)
        {
            if (this._isInInvalidateBinding)
            {
                return;
            }
            this._isInInvalidateBinding = true;
            int num = this.MutableBindingExpressions.IndexOf(bindingExpression);
            DependencyObject targetElement = base.TargetElement;

            if (targetElement != null && 0 <= num && num < this.AttentiveBindingExpressions)
            {
                if (num != this._activeIndex || (bindingExpression.StatusInternal != BindingStatusInternal.Active && !bindingExpression.UsingFallbackValue))
                {
                    this.ChooseActiveBindingExpression(targetElement);
                }
                base.UsingFallbackValue = false;
                BindingExpressionBase activeBindingExpression = this.ActiveBindingExpression;
                object obj = (activeBindingExpression != null) ? activeBindingExpression.GetValue(targetElement, base.TargetProperty) : base.UseFallbackValue();
                base.ChangeValue(obj, true);
                if (TraceData.IsExtendedTraceEnabled(this, TraceDataLevel.Transfer))
                {
                    TraceData.Trace(TraceEventType.Warning, TraceData.PriorityTransfer(new object[]
                    {
                        TraceData.Identify(this),
                        TraceData.Identify(obj),
                        this._activeIndex,
                        TraceData.Identify(activeBindingExpression)
                    }));
                }
                if (!base.IsAttaching)
                {
                    targetElement.InvalidateProperty(base.TargetProperty);
                }
            }
            this._isInInvalidateBinding = false;
        }