Example #1
0
        private bool TryEvaluateif(IMvxSourceStep testStep, IMvxSourceStep ifStep, IMvxSourceStep elseStep, out object value)
        {
            var result = testStep.GetValue();

            if (result == MvxBindingConstant.DoNothing)
            {
                value = MvxBindingConstant.DoNothing;
                return(true);
            }

            if (result == MvxBindingConstant.UnsetValue)
            {
                value = MvxBindingConstant.UnsetValue;
                return(true);
            }

            if (IsTrue(result))
            {
                value = ReturnSubStepResult(ifStep);
                return(true);
            }

            value = ReturnSubStepResult(elseStep);
            return(true);
        }
Example #2
0
        private void CreateSourceBinding(object source)
        {
            // NOTE: We do not call the setter for DataContext here because we are
            // setting up the sourceStep.
            // If that method is updated we will need to make sure that this method
            // does the right thing.
            this._dataContext            = source;
            this._sourceStep             = this.SourceStepFactory.Create(this._bindingDescription.Source);
            this._sourceStep.TargetType  = this._targetBinding.TargetType;
            this._sourceStep.DataContext = source;

            if (this.NeedToObserveSourceChanges)
            {
                this._sourceBindingOnChanged = (sender, args) =>
                {
                    //Capture the cancel token first
                    var cancel = _cancelSource.Token;
                    //GetValue can now be executed in a worker thread. Is it the responsibility of the caller to switch threads, or ours ?
                    //As the source is the viewmodel, i suppose it is the responsibility of the caller.
                    var value = this._sourceStep.GetValue();
                    this.UpdateTargetFromSource(value, cancel);
                };
                this._sourceStep.Changed += this._sourceBindingOnChanged;
            }

            this.UpdateTargetOnBind();
        }
Example #3
0
 protected virtual object ReturnSubStepResult(IMvxSourceStep subStep)
 {
     if (subStep == null)
     {
         return(MvxBindingConstant.UnsetValue);
     }
     return(subStep.GetValue());
 }
 protected virtual object ReturnSubStepResult(IMvxSourceStep subStep)
 {
     if (subStep == null)
     {
         return MvxBindingConstant.UnsetValue;
     }
     return subStep.GetValue();
 }
Example #5
0
        protected virtual void ClearSourceBinding()
        {
            if (this._sourceStep != null)
            {
                if (this._sourceBindingOnChanged != null)
                {
                    this._sourceStep.Changed    -= this._sourceBindingOnChanged;
                    this._sourceBindingOnChanged = null;
                }

                this._sourceStep.Dispose();
                this._sourceStep = null;
            }
        }
Example #6
0
        protected virtual void ClearSourceBinding()
        {
            if (_sourceStep != null)
            {
                if (_sourceBindingOnChanged != null)
                {
                    _sourceStep.Changed    -= _sourceBindingOnChanged;
                    _sourceBindingOnChanged = null;
                }

                _sourceStep.Dispose();
                _sourceStep = null;
            }
        }
Example #7
0
        protected virtual void ClearSourceBinding()
        {
            if (this._sourceStep != null)
            {
                if (this._sourceBindingOnChanged != null)
                {
                    this._sourceStep.Changed -= this._sourceBindingOnChanged;
                    this._sourceBindingOnChanged = null;
                }

                this._sourceStep.Dispose();
                this._sourceStep = null;
            }
        }
Example #8
0
        protected virtual void ClearSourceBinding()
        {
            if (_sourceStep != null)
            {
                if (_sourceBindingOnChanged != null)
                {
                    _sourceStep.Changed -= _sourceBindingOnChanged;
                    _sourceBindingOnChanged = null;
                }

                _sourceStep.Dispose();
                _sourceStep = null;
            }
        }
Example #9
0
        private void CreateSourceBinding(object source)
        {
            _dataContext            = source;
            _sourceStep             = SourceStepFactory.Create(_bindingDescription.Source);
            _sourceStep.TargetType  = _targetBinding.TargetType;
            _sourceStep.DataContext = source;

            if (NeedToObserveSourceChanges)
            {
                _sourceBindingOnChanged = (sender, args) =>
                {
                    var value = _sourceStep.GetValue();
                    UpdateTargetFromSource(value);
                };
                _sourceStep.Changed += _sourceBindingOnChanged;
            }

            UpdateTargetOnBind();
        }
Example #10
0
        private void CreateSourceBinding(object source)
        {
            _dataContext = source;
            _sourceStep = SourceStepFactory.Create(_bindingDescription.Source);
            _sourceStep.TargetType = _targetBinding.TargetType;
            _sourceStep.DataContext = source;

            if (NeedToObserveSourceChanges)
            {
                _sourceBindingOnChanged = (sender, args) =>
                    {
                        var value = _sourceStep.GetValue();
                        UpdateTargetFromSource(value);
                    };
                _sourceStep.Changed += _sourceBindingOnChanged;
            }

            UpdateTargetOnBind();
        }
        private void CreateSourceBinding(object source)
        {
            this._dataContext            = source;
            this._sourceStep             = this.SourceStepFactory.Create(this._bindingDescription.Source);
            this._sourceStep.TargetType  = this._targetBinding.TargetType;
            this._sourceStep.DataContext = source;

            if (this.NeedToObserveSourceChanges)
            {
                this._sourceBindingOnChanged = (sender, args) =>
                {
                    //Capture the cancel token first
                    var cancel = _cancelSource.Token;
                    //GetValue can now be executed in a worker thread. Is it the responsibility of the caller to switch threads, or ours ?
                    //As the source is the viewmodel, i suppose it is the responsibility of the caller.
                    var value = this._sourceStep.GetValue();
                    this.UpdateTargetFromSource(value, cancel);
                };
                this._sourceStep.Changed += this._sourceBindingOnChanged;
            }

            this.UpdateTargetOnBind();
        }
Example #12
0
        private void CreateSourceBinding(object source)
        {
            this._dataContext = source;
            this._sourceStep = this.SourceStepFactory.Create(this._bindingDescription.Source);
            this._sourceStep.TargetType = this._targetBinding.TargetType;
            this._sourceStep.DataContext = source;

            if (this.NeedToObserveSourceChanges)
            {
                this._sourceBindingOnChanged = (sender, args) =>
                    {
                        //Capture the cancel token first
                        var cancel = _cancelSource.Token;
                        //GetValue can now be executed in a worker thread. Is it the responsibility of the caller to switch threads, or ours ?
                        //As the source is the viewmodel, i suppose it is the responsibility of the caller.
                        var value = this._sourceStep.GetValue();
                        this.UpdateTargetFromSource(value, cancel);
                    };
                this._sourceStep.Changed += this._sourceBindingOnChanged;
            }

            this.UpdateTargetOnBind();
        }
        private bool TryEvaluateIf(IMvxSourceStep testStep, IMvxSourceStep ifStep, IMvxSourceStep elseStep, out object value)
        {
            var result = testStep.GetValue();
            if (result == MvxBindingConstant.DoNothing)
            {
                value = MvxBindingConstant.DoNothing;
                return true;
            }

            if (result == MvxBindingConstant.UnsetValue)
            {
                value = MvxBindingConstant.UnsetValue;
                return true;
            }

            if (IsTrue(result))
            {
                value = ReturnSubStepResult(ifStep);
                return true;
            }

            value = ReturnSubStepResult(elseStep);
            return true;
        }