예제 #1
0
        public ApplyValueResult TryApplyToInstance()
        {
            object newValue;

            if (HasUserChangedAnything)
            {
                var result = mContainer.TryGetValueOnUi(out newValue);

                if (result == ApplyValueResult.Success)
                {
                    if (InstanceMember.BeforeSetByUi != null)
                    {
                        InstanceMember.CallBeforeSetByUi(mContainer);
                    }

                    // Hold on, the Before set may have actually changed the value, so we should get the value again.
                    mContainer.TryGetValueOnUi(out newValue);

                    if (newValue is string)
                    {
                        newValue = (newValue as string).Replace("\r", "");
                    }
                    // get rid of \r
                    return(mContainer.TrySetValueOnInstance(newValue));
                }
                else
                {
                    if (InstanceMember.SetValueError != null)
                    {
                        InstanceMember.SetValueError(mAssociatedTextBox.Text);
                    }
                }
            }
            return(ApplyValueResult.Success);
        }
예제 #2
0
        public ApplyValueResult TryApplyToInstance()
        {
            object newValue;

            if (HasUserChangedAnything)
            {
                if (mContainer.TryGetValueOnUi(out newValue) == ApplyValueResult.Success)
                {
                    if (InstanceMember.BeforeSetByUi != null)
                    {
                        InstanceMember.CallBeforeSetByUi(mContainer);
                    }

                    // Hold on, the Before set may have actually changed the value, so we should get the value again.
                    mContainer.TryGetValueOnUi(out newValue);


                    return(mContainer.TrySetValueOnInstance(newValue));
                }
            }
            return(ApplyValueResult.Success);
        }