Exemplo n.º 1
0
        internal static MemberSlot Create(ViewProxy proxy, MemberMeta member)
        {
            if (member.IsCollection)
            {
                if (member.IsObservableCollection)
                {
                    return(new PassThroughSlot(proxy, member));
                }
                else if (member.IsList)
                {
                    return(new ListSlot(proxy, member));
                }
                else
                {
#if NETFRAMEWORK
                    if (BindingListSlot.AppliesTo(member))
                    {
                        return(new BindingListSlot(proxy, member));
                    }
                    else
                    {
                        return(new CollectionSlot(proxy, member));
                    }
#else
                    return(new CollectionSlot(proxy, member));
#endif
                }
            }
            else
            {
                return(new AtomSlot(proxy, member));
            }
        }
Exemplo n.º 2
0
 internal static MemberSlot Create(ViewProxy proxy, MemberMeta member)
 {
     if (member.IsCollection)
     {
         return(new CollectionSlot(proxy, member));
     }
     else
     {
         return(new AtomSlot(proxy, member));
     }
 }
Exemplo n.º 3
0
        public BindingListSlot(ViewProxy proxy, MemberMeta member)
            : base(proxy, member)
        {
            _newItemMethod    = GetNewItemMethod(member);
            _deleteItemMethod = GetDeleteItemMethod(member);

            _bindingList.AllowNew     = true;
            _bindingList.AllowEdit    = true;
            _bindingList.AllowRemove  = true;
            _bindingList.AddingNew   += BindingList_AddingNew;
            _bindingList.ListChanged += BindingList_ListChanged;
        }
Exemplo n.º 4
0
 protected MemberSlot(ViewProxy proxy, MemberMeta member)
 {
     Proxy  = proxy;
     Member = member;
     if (member.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _computed = new Computed(() => BindingInterceptor.Current.UpdateValue(this));
         // When the property becomes out of date, trigger an update.
         // The update should have lower priority than user input & drawing,
         // to ensure that the app doesn't lock up in case a large model is
         // being updated outside the UI (e.g. via timers or the network).
         _computed.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
     }
 }
Exemplo n.º 5
0
        public ListSlot(ViewProxy proxy, MemberMeta member)
            : base(proxy, member)
        {
            _collectionChangedFromUIEventHandler = new NotifyCollectionChangedEventHandler((s, e) =>
            {
                if (!_publishingChanges)
                {
                    switch (e.Action)
                    {
                    case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                        foreach (var item in e.NewItems)
                        {
                            _sourceCollection.Add(UnwrapValue(item));
                        }
                        _computed.MakeDependentsOutOfDate();
                        break;

                    case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                        foreach (var item in e.OldItems)
                        {
                            _sourceCollection.Remove(UnwrapValue(item));
                        }
                        _computed.MakeDependentsOutOfDate();
                        break;

                    case NotifyCollectionChangedAction.Reset:
                        _sourceCollection.Clear();
                        _computed.MakeDependentsOutOfDate();
                        break;

                    default:
                        break;
                    }

                    if (Proxy.IsNotifying)
                    {
                        // The view is modifying the list in response to another update.
                        // After it stops, notify it of other changes so that it can get the correct list.
                        Proxy.WasModified(this);
                    }
                }
            });
        }
Exemplo n.º 6
0
 internal AtomSlot(ViewProxy proxy, MemberMeta member)
     : base(proxy, member)
 {
 }
Exemplo n.º 7
0
 public PassThroughSlot(ViewProxy proxy, MemberMeta member) : base(proxy, member)
 {
 }
Exemplo n.º 8
0
 public CollectionSlot(ViewProxy proxy, MemberMeta member)
     : base(proxy, member)
 {
 }