internal void SetExpressionValue(object value, object baseValue)
        {
            ModifiedValue modifiedValue = this.EnsureModifiedValue();

            modifiedValue.ExpressionValue = value;
            this.IsExpression             = true;
            global::System.Diagnostics.Debug.Assert(object.Equals(baseValue, modifiedValue.BaseValue));
        }
 internal void ResetValue()
 {
     if (this.HasModifiers)
     {
         ModifiedValue modifiedValue = this.ModifiedValue;
         this._source &= FullValueSource.ValueSourceMask;
         this.Value    = modifiedValue.BaseValue;
     }
 }
        internal void SetExpressionFromStyleValue(object value, object baseValue)
        {
            ModifiedValue modifiedValue = this.EnsureModifiedValue();

            global::System.Diagnostics.Debug.Assert(modifiedValue.ExpressionValue == null, "Can't set expression from style if local expression is set");
            modifiedValue.ExpressionValue = value;
            this.IsExpressionFromStyle    = true;
            global::System.Diagnostics.Debug.Assert(object.Equals(baseValue, modifiedValue.BaseValue));
        }
        internal void ResetExpressionFromStyleValue()
        {
            if (this.IsExpressionFromStyle)
            {
                ModifiedValue modifiedValue = this.ModifiedValue;
                modifiedValue.ExpressionValue = null;
                this.IsExpressionFromStyle    = false;

                if (!this.HasModifiers)
                {
                    this.Value = modifiedValue.BaseValue;
                }
            }
        }
        internal void ResetCoercedValue()
        {
            if (this.IsCoerced)
            {
                ModifiedValue modifiedValue = this.ModifiedValue;
                modifiedValue.CoercedValue = null;
                this.IsCoerced             = false;

                if (!this.HasModifiers)
                {
                    this.Value = modifiedValue.BaseValue;
                }
            }
        }
        internal void SetCoercedValue(object value, object baseValue, bool coerceWithCurrentValue)
        {
            ModifiedValue modifiedValue = this.EnsureModifiedValue();

            if (this.IsCoercedWithCurrentValue)
            {
                baseValue = modifiedValue.BaseValue;
            }
            modifiedValue.CoercedValue     = value;
            this.IsCoerced                 = true;
            this.IsCoercedWithCurrentValue = coerceWithCurrentValue;
            global::System.Diagnostics.Debug.Assert(object.Equals(baseValue, modifiedValue.BaseValue) ||
                                                    object.Equals(baseValue, modifiedValue.ExpressionValue));
        }
        private ModifiedValue EnsureModifiedValue()
        {
            ModifiedValue modifiedValue;

            if (this._value == null)
            {
                this._value = modifiedValue = new ModifiedValue();
            }
            else
            {
                modifiedValue = this._value as ModifiedValue;
                if (modifiedValue == null)
                {
                    modifiedValue           = new ModifiedValue();
                    modifiedValue.BaseValue = this._value;
                    this._value             = modifiedValue;
                }
            }
            return(modifiedValue);
        }