Esempio n. 1
0
            private void UpdateContextInternal()
            {
                if (!_isParentContext)
                {
                    return;
                }
                ClearOldContext();
                object target = _targetReference.Target;

                if (target == null)
                {
                    return;
                }
                var context = GetParentBindingContext(target);

                if (context == null)
                {
                    _dataContext = null;
                }
                else
                {
                    var source = context.Source;
                    if (source != null)
                    {
                        WeakEventManager.GetBindingContextListener(source).Add(this);
                    }
                    _dataContext = context;
                }
            }
 private void Update(object source)
 {
     if (_parentContext != null)
     {
         var src = _parentContext.Source;
         if (src != null)
         {
             WeakEventManager.GetBindingContextListener(src).Remove(this);
         }
     }
     if (source == null)
     {
         _parentContext = null;
     }
     else
     {
         _parentContext = GetParentBindingContext(source);
         if (_parentContext != null)
         {
             var src = _parentContext.Source;
             if (src != null)
             {
                 WeakEventManager.GetBindingContextListener(src).Add(this);
             }
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 ///     Attempts to track the value change.
 /// </summary>
 public IDisposable TryObserve(object source, IEventListener listener)
 {
     if (_isDataContext)
     {
         return(WeakEventManager.GetBindingContextListener(source).AddWithUnsubscriber(listener));
     }
     if (_memberEvent == null)
     {
         return(null);
     }
     return(_memberEvent.SetValue(source, new object[] { listener }) as IDisposable);
 }
Esempio n. 4
0
            private void ClearOldContext()
            {
                var bindingContext = _dataContext as IBindingContext;

                if (bindingContext != null)
                {
                    var source = bindingContext.Source;
                    if (source != null)
                    {
                        WeakEventManager.GetBindingContextListener(source).Remove(this);
                    }
                }
            }