Beispiel #1
0
 public override object GetValue()
 {
     if (_currentChildBinding == null)
     {
         return(MvxBindingConstant.UnsetValue);
     }
     return(_currentChildBinding.GetValue());
 }
        protected override object GetSourceValue()
        {
            if (_sourceBinding == null)
            {
                return(MvxBindingConstant.UnsetValue);
            }

            return(_sourceBinding.GetValue());
        }
Beispiel #3
0
        public ObservableMvxSourceBinding(IObservable <T> source, Type sourceType, IMvxMainThreadDispatcher mainThreadDispatcher, IList <MvxPropertyToken> remainingTokens)
        {
            Contract.Requires(source != null);
            Contract.Requires(sourceType != null);

            this._sourceType = sourceType;

            if (mainThreadDispatcher != null)
            {
                source = source.ObserveOn(mainThreadDispatcher);
            }

            this._sourceSubscription = source
                                       .Subscribe(value =>
            {
                this._currentValue = value;

                if (this._currentSubBinding != null)
                {
                    this._currentSubBinding.Dispose();
                    this._currentSubBinding = null;
                }

                if (this._currentSubBindingSubscription != null)
                {
                    this._currentSubBindingSubscription.Dispose();
                    this._currentSubBindingSubscription = null;
                }

                IMvxSourceBinding newSubBinding = null;
                if ((remainingTokens != null) && (remainingTokens.Count > 0))
                {
                    newSubBinding = MvxSingleton <IMvxBindingSingletonCache> .Instance.SourceBindingFactory.CreateBinding(value, remainingTokens);
                }

                var subBindingObservable = (newSubBinding != null)
                        ? Observable
                                           .Return <object>(null)
                                           .Concat(Observable
                                                   .FromEventPattern(eh => newSubBinding.Changed += eh, eh => newSubBinding.Changed -= eh))
                                           .Select(x => newSubBinding.GetValue())
                                           .Select(x => (x as IObservable <object>) ?? Observable.Return(x))
                                           .Switch()
                        : Observable.Return <object>(null);

                this._currentSubBinding = newSubBinding;

                this._currentSubBindingSubscription = subBindingObservable.Subscribe((value2 =>
                {
                    var changed2 = this.Changed;
                    if (changed2 != null)
                    {
                        changed2(this, EventArgs.Empty);
                    }
                }));
            });
        }
 public MvxSourcePropertyBindingEventArgs(IMvxSourceBinding propertySourceBinding)
 {
     _value = propertySourceBinding.GetValue();
 }
 public MvxSourcePropertyBindingEventArgs(IMvxSourceBinding propertySourceBinding)
 {
     _value = propertySourceBinding.GetValue();
 }