private void SetValue(object newValue)
            {
                if (newValue == null)
                {
                    UnsubscribeCommand();
                    _valueReference = null;
                    return;
                }

                var command = newValue as ICommand;

                if (command == null)
                {
                    if (!(newValue is BindingActionValue))
                    {
                        throw BindingExceptionManager.InvalidEventSourceValue(_currentValue.Member, newValue);
                    }
                    _valueReference = newValue;
                }
                else
                {
                    var reference = _valueReference as WeakReference;
                    if (reference != null && ReferenceEquals(reference.Target, command))
                    {
                        return;
                    }
                    UnsubscribeCommand();
                    _valueReference = ToolkitExtensions.GetWeakReferenceOrDefault(command, null, true);
                    if (_toggleEnabledState && InitializeCanExecuteDelegate(command))
                    {
                        CommandOnCanExecuteChanged(command);
                        command.CanExecuteChanged += _canExecuteHandler;
                    }
                }
            }
Exemple #2
0
 private void SetParent(object source, object value)
 {
     if (source == null || ReferenceEquals(value, _parent.Target))
         return;
     _parent = ToolkitExtensions.GetWeakReferenceOrDefault(value, Empty.WeakReference, false);
     Raise(source, EventArgs.Empty);
 }
Exemple #3
0
 private ParentObserver(FrameworkElement view)
 {
     _view = ServiceProvider.WeakReferenceFactory(view);
     _parent = ToolkitExtensions.GetWeakReferenceOrDefault(FindParent(view), Empty.WeakReference, false);
     RoutedEventHandler handler = OnChanged;
     view.Loaded += handler;
     view.Unloaded += handler;
 }
        private void SetParent(object value)
        {
            var view = GetSource();

            if (view == null)
            {
                return;
            }

            if (ReferenceEquals(value, _parent.Target))
            {
                return;
            }
            _parent = ToolkitExtensions.GetWeakReferenceOrDefault(value, Empty.WeakReference, false);
            Raise(view, EventArgs.Empty);
        }
            private void SetValue(object newValue, IBindingPathMembers pathMembers)
            {
                if (newValue == null)
                {
                    UnsubscribeCommand();
                    _valueReference = null;
                    return;
                }

                var command = newValue as ICommand;

                if (command == null)
                {
                    if (!(newValue is BindingActionValue))
                    {
                        throw BindingExceptionManager.InvalidEventSourceValue(_currentValue.Member, newValue);
                    }
                    _valueReference = newValue;
                    if (_path.IsDebuggable)
                    {
                        DebugInfo($"Binding will use event: '{pathMembers.LastMember.Path}' to update member: '{((BindingActionValue)newValue).Member.Path}'", new[] { newValue });
                    }
                }
                else
                {
                    var reference = _valueReference as WeakReference;
                    if (reference != null && ReferenceEquals(reference.Target, command))
                    {
                        return;
                    }
                    if (_path.IsDebuggable)
                    {
                        DebugInfo($"Binding will use event: '{pathMembers.LastMember.Path}' to update command: '{newValue}'", new[] { newValue });
                    }
                    UnsubscribeCommand();
                    _valueReference = ToolkitExtensions.GetWeakReferenceOrDefault(command, null, true);
                    if (_toggleEnabledState && InitializeCanExecuteDelegate(command))
                    {
                        CommandOnCanExecuteChanged(command);
                        command.CanExecuteChanged += _canExecuteHandler;
                    }
                }
            }
Exemple #6
0
        private UIView RaiseInternal()
        {
            var view = GetSource();

            if (_isAttached || view == null)
            {
                return(view);
            }

            object parent = GetParent(view);

            if (ReferenceEquals(parent, _parent.Target))
            {
                return(view);
            }
            _parent = ToolkitExtensions.GetWeakReferenceOrDefault(parent, Empty.WeakReference, false);
            Raise(view, EventArgs.Empty);
            return(view);
        }
        public void Raise()
        {
            if (_isAttached)
            {
                return;
            }
            var view = GetSource();

            if (view == null)
            {
                return;
            }
            var parent = GetParent(view);

            if (view.Id == global::Android.Resource.Id.Content || ReferenceEquals(parent, _parent.Target))
            {
                return;
            }
            _parent = ToolkitExtensions.GetWeakReferenceOrDefault(parent, Empty.WeakReference, false);
            Raise(view, EventArgs.Empty);
        }
 private ParentObserver(View view)
 {
     _view   = ServiceProvider.WeakReferenceFactory(view);
     _parent = ToolkitExtensions.GetWeakReferenceOrDefault(GetParent(view), Empty.WeakReference, false);
 }
Exemple #9
0
 private ParentObserver(Element view)
 {
     _view   = ServiceProvider.WeakReferenceFactory(view);
     _parent = ToolkitExtensions.GetWeakReferenceOrDefault(FindParent(view), Empty.WeakReference, false);
     view.PropertyChanged += OnPropertyChanged;
 }