Ejemplo n.º 1
0
        /// <summary>
        ///     Allows Expression to store set values
        /// </summary>
        /// <param name="d">DependencyObject being set</param>
        /// <param name="dp">Property being set</param>
        /// <param name="value">Value being set</param>
        /// <returns>true if Expression handled storing of the value</returns>
        internal override bool SetValue(DependencyObject d, DependencyProperty dp, object value)
        {
            bool result;
            BindingExpressionBase bindExpr = ActiveBindingExpression;

            if (bindExpr != null)
            {
                result = bindExpr.SetValue(d, dp, value);
                if (result)
                {
                    // the active binding's value becomes the value of the priority binding
                    Value = bindExpr.Value;

                    AdoptProperties(bindExpr);
                    NotifyCommitManager();
                }
            }
            else
            {
                // If we couldn't find the active binding, just return true to keep the property
                // engine from removing the PriorityBinding.
                result = true;
            }

            return(result);
        }
        // Token: 0x06001C6F RID: 7279 RVA: 0x00085BB4 File Offset: 0x00083DB4
        internal override bool SetValue(DependencyObject d, DependencyProperty dp, object value)
        {
            BindingExpressionBase activeBindingExpression = this.ActiveBindingExpression;
            bool flag;

            if (activeBindingExpression != null)
            {
                flag = activeBindingExpression.SetValue(d, dp, value);
                if (flag)
                {
                    base.Value = activeBindingExpression.Value;
                    base.AdoptProperties(activeBindingExpression);
                    base.NotifyCommitManager();
                }
            }
            else
            {
                flag = true;
            }
            return(flag);
        }
Ejemplo n.º 3
0
        // Token: 0x06001C2E RID: 7214 RVA: 0x000844B0 File Offset: 0x000826B0
        private bool ConvertProposedValueImpl(object value, out object result)
        {
            DependencyObject targetElement = base.TargetElement;

            if (targetElement == null)
            {
                result = DependencyProperty.UnsetValue;
                return(false);
            }
            result = this.GetValuesForChildBindings(value);
            if (base.IsDetached)
            {
                return(false);
            }
            if (result == DependencyProperty.UnsetValue)
            {
                base.SetStatus(BindingStatusInternal.UpdateSourceError);
                return(false);
            }
            object[] array = (object[])result;
            if (array == null)
            {
                if (TraceData.IsEnabled)
                {
                    TraceData.Trace(TraceEventType.Error, TraceData.BadMultiConverterForUpdate(new object[]
                    {
                        this.Converter.GetType().Name,
                        AvTrace.ToStringHelper(value),
                        AvTrace.TypeName(value)
                    }), this);
                }
                result = DependencyProperty.UnsetValue;
                return(false);
            }
            if (TraceData.IsExtendedTraceEnabled(this, TraceDataLevel.Transfer))
            {
                for (int i = 0; i < array.Length; i++)
                {
                    TraceData.Trace(TraceEventType.Warning, TraceData.UserConvertBackMulti(new object[]
                    {
                        TraceData.Identify(this),
                        i,
                        TraceData.Identify(array[i])
                    }));
                }
            }
            int num = this.MutableBindingExpressions.Count;

            if (array.Length != num && TraceData.IsEnabled)
            {
                TraceData.Trace(TraceEventType.Information, TraceData.MultiValueConverterMismatch, new object[]
                {
                    this.Converter.GetType().Name,
                    num,
                    array.Length,
                    TraceData.DescribeTarget(targetElement, base.TargetProperty)
                });
            }
            if (array.Length < num)
            {
                num = array.Length;
            }
            bool result2 = true;

            for (int j = 0; j < num; j++)
            {
                value = array[j];
                if (value != Binding.DoNothing && value != DependencyProperty.UnsetValue)
                {
                    BindingExpressionBase bindingExpressionBase = this.MutableBindingExpressions[j];
                    bindingExpressionBase.SetValue(targetElement, base.TargetProperty, value);
                    value = bindingExpressionBase.GetRawProposedValue();
                    if (!bindingExpressionBase.Validate(value, ValidationStep.RawProposedValue))
                    {
                        value = DependencyProperty.UnsetValue;
                    }
                    value = bindingExpressionBase.ConvertProposedValue(value);
                }
                else if (value == DependencyProperty.UnsetValue && TraceData.IsEnabled)
                {
                    TraceData.Trace(TraceEventType.Information, TraceData.UnsetValueInMultiBindingExpressionUpdate(new object[]
                    {
                        this.Converter.GetType().Name,
                        AvTrace.ToStringHelper(value),
                        j,
                        this._tempTypes[j]
                    }), this);
                }
                if (value == DependencyProperty.UnsetValue)
                {
                    result2 = false;
                }
                array[j] = value;
            }
            Array.Clear(this._tempTypes, 0, this._tempTypes.Length);
            result = array;
            return(result2);
        }