Example #1
0
        // Token: 0x06001C41 RID: 7233 RVA: 0x00084DEC File Offset: 0x00082FEC
        private void TransferValue()
        {
            base.IsInTransfer      = true;
            base.NeedsDataTransfer = false;
            DependencyObject targetElement = base.TargetElement;

            if (targetElement != null)
            {
                bool        flag    = TraceData.IsExtendedTraceEnabled(this, TraceDataLevel.Transfer);
                object      obj     = DependencyProperty.UnsetValue;
                object      obj2    = this._tempValues;
                CultureInfo culture = base.GetCulture();
                int         count   = this.MutableBindingExpressions.Count;
                for (int i = 0; i < count; i++)
                {
                    this._tempValues[i] = this.MutableBindingExpressions[i].GetValue(targetElement, base.TargetProperty);
                    if (flag)
                    {
                        TraceData.Trace(TraceEventType.Warning, TraceData.GetRawValueMulti(new object[]
                        {
                            TraceData.Identify(this),
                            i,
                            TraceData.Identify(this._tempValues[i])
                        }));
                    }
                }
                if (this.Converter != null)
                {
                    obj2 = this.Converter.Convert(this._tempValues, base.TargetProperty.PropertyType, this.ParentMultiBinding.ConverterParameter, culture);
                    if (base.IsDetached)
                    {
                        return;
                    }
                    if (flag)
                    {
                        TraceData.Trace(TraceEventType.Warning, TraceData.UserConverter(new object[]
                        {
                            TraceData.Identify(this),
                            TraceData.Identify(obj2)
                        }));
                    }
                }
                else if (base.EffectiveStringFormat != null)
                {
                    for (int j = 0; j < this._tempValues.Length; j++)
                    {
                        if (this._tempValues[j] == DependencyProperty.UnsetValue)
                        {
                            obj2 = DependencyProperty.UnsetValue;
                            break;
                        }
                    }
                }
                else
                {
                    if (TraceData.IsEnabled)
                    {
                        TraceData.Trace(TraceEventType.Error, TraceData.MultiValueConverterMissingForTransfer, this);
                        goto IL_371;
                    }
                    goto IL_371;
                }
                if (base.EffectiveStringFormat == null || obj2 == Binding.DoNothing || obj2 == DependencyProperty.UnsetValue)
                {
                    obj = obj2;
                }
                else
                {
                    try
                    {
                        if (obj2 == this._tempValues)
                        {
                            obj = string.Format(culture, base.EffectiveStringFormat, this._tempValues);
                        }
                        else
                        {
                            obj = string.Format(culture, base.EffectiveStringFormat, new object[]
                            {
                                obj2
                            });
                        }
                        if (flag)
                        {
                            TraceData.Trace(TraceEventType.Warning, TraceData.FormattedValue(new object[]
                            {
                                TraceData.Identify(this),
                                TraceData.Identify(obj)
                            }));
                        }
                    }
                    catch (FormatException)
                    {
                        obj = DependencyProperty.UnsetValue;
                        if (flag)
                        {
                            TraceData.Trace(TraceEventType.Warning, TraceData.FormattingFailed(new object[]
                            {
                                TraceData.Identify(this),
                                base.EffectiveStringFormat
                            }));
                        }
                    }
                }
                Array.Clear(this._tempValues, 0, this._tempValues.Length);
                if (obj != Binding.DoNothing)
                {
                    if (base.EffectiveTargetNullValue != DependencyProperty.UnsetValue && BindingExpressionBase.IsNullValue(obj))
                    {
                        obj = base.EffectiveTargetNullValue;
                        if (flag)
                        {
                            TraceData.Trace(TraceEventType.Warning, TraceData.NullConverter(new object[]
                            {
                                TraceData.Identify(this),
                                TraceData.Identify(obj)
                            }));
                        }
                    }
                    if (obj != DependencyProperty.UnsetValue && !base.TargetProperty.IsValidValue(obj))
                    {
                        if (TraceData.IsEnabled)
                        {
                            TraceData.Trace(base.TraceLevel, TraceData.BadValueAtTransfer, obj, this);
                        }
                        if (flag)
                        {
                            TraceData.Trace(TraceEventType.Warning, TraceData.BadValueAtTransferExtended(new object[]
                            {
                                TraceData.Identify(this),
                                TraceData.Identify(obj)
                            }));
                        }
                        obj = DependencyProperty.UnsetValue;
                    }
                    if (obj == DependencyProperty.UnsetValue)
                    {
                        obj = base.UseFallbackValue();
                        if (flag)
                        {
                            TraceData.Trace(TraceEventType.Warning, TraceData.UseFallback(new object[]
                            {
                                TraceData.Identify(this),
                                TraceData.Identify(obj)
                            }));
                        }
                    }
                    if (flag)
                    {
                        TraceData.Trace(TraceEventType.Warning, TraceData.TransferValue(new object[]
                        {
                            TraceData.Identify(this),
                            TraceData.Identify(obj)
                        }));
                    }
                    bool flag2 = !base.IsInUpdate || !ItemsControl.EqualsEx(obj, base.Value);
                    if (flag2)
                    {
                        base.ChangeValue(obj, true);
                        base.Invalidate(false);
                        Validation.ClearInvalid(this);
                    }
                    base.Clean();
                    if (flag2)
                    {
                        this.OnTargetUpdated();
                    }
                }
            }
IL_371:
            base.IsInTransfer = false;
        }