示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntityList{T}"/> with the specified
        /// <paramref name="source"/>
        /// </summary>
        /// <param name="entitySet">The
        /// <see cref="OpenRiaServices.DomainServices.Client.EntitySet{T}"/> that backs this list. All
        /// items added or removed from this list will also be added or removed from the backing
        /// <see cref="EntitySet"/>.
        /// </param>
        /// <param name="source">The source collection used to populate this list</param>
        public EntityList(EntitySet <T> entitySet, IEnumerable <T> source)
        {
            if (entitySet == null)
            {
                throw new ArgumentNullException("entitySet");
            }

            this._entitySet = entitySet;
            this._weakCollectionChangedLister =
                WeakCollectionChangedListener.CreateIfNecessary(this._entitySet, this);

            this.Source = source;
        }
 private void DisconnectListener()
 {
     this.indexer = null;
     if (this.collectionChangedListener != null)
     {
         this.collectionChangedListener.Disconnect();
         this.collectionChangedListener = null;
     }
     if (this.propertyListener != null)
     {
         this.propertyListener.Disconnect();
         this.propertyListener = null;
     }
 }
示例#3
0
        private static void OnSpecialSlotsSourcePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            MultiDayViewSettings     settings       = (MultiDayViewSettings)sender;
            INotifyCollectionChanged oldSlotsSource = args.OldValue as INotifyCollectionChanged;

            if (oldSlotsSource != null)
            {
                var listener = settings.specialSlotsCollectionChangedListener;
                if (listener != null)
                {
                    listener.Detach();
                    listener = null;
                }

                int count = settings.specialSlotsPropertyChangedListeners != null ? settings.specialSlotsPropertyChangedListeners.Count : 0;
                while (count > 0)
                {
                    var propertyListener = settings.specialSlotsPropertyChangedListeners[0];
                    settings.specialSlotsPropertyChangedListeners.RemoveAt(0);
                    propertyListener.Detach();
                    propertyListener = null;
                    count--;
                }
            }

            INotifyCollectionChanged newSlotsSource = args.NewValue as INotifyCollectionChanged;

            if (newSlotsSource != null)
            {
                settings.specialSlotsCollectionChangedListener = WeakCollectionChangedListener.CreateIfNecessary(newSlotsSource, settings);

                foreach (Slot slot in (IEnumerable <Slot>)newSlotsSource)
                {
                    var listener = WeakPropertyChangedListener.CreateIfNecessary(slot, settings);
                    if (listener != null)
                    {
                        settings.specialSlotsPropertyChangedListeners.Add(listener);
                    }
                }
            }

            if (oldSlotsSource != null && settings.IsOwnerLoaded)
            {
                settings.owner.timeRulerLayer.RecycleSlots((IEnumerable <Slot>)oldSlotsSource);
            }

            settings.Invalide(MultiDayViewUpdateFlag.AffectsSpecialSlots);
        }
 private bool ConnectToIndexerInSource()
 {
     if (this.source == null || this.source == DependencyProperty.UnsetValue)
     {
         return(false);
     }
     this.indexer = this.FindIndexerProperty(this.source);
     if (this.indexer == null)
     {
         return(false);
     }
     if (this.propertyListener == null)
     {
         this.propertyListener = IndexerListener.CreateListener(this, this.source, this.index, this.intIndexer, this.indexer, this.listenToChanges);
     }
     if (this.listenToChanges)
     {
         this.collectionChangedListener = WeakCollectionChangedListener.CreateIfNecessary(this.source, this);
     }
     return(true);
 }
示例#5
0
 private void DisconnectListener()
 {
     this.indexer = null;
     if (this.collectionChangedListener != null)
     {
         this.collectionChangedListener.Disconnect();
         this.collectionChangedListener = null;
     }
     if (this.propertyListener != null)
     {
         this.propertyListener.Disconnect();
         this.propertyListener = null;
     }
 }
示例#6
0
 private bool ConnectToIndexerInSource()
 {
     if (this.source == null || this.source == DependencyProperty.UnsetValue)
     {
         return false;
     }
     this.indexer = this.FindIndexerProperty(this.source);
     if (this.indexer == null)
     {
         return false;
     }
     if (this.propertyListener == null)
     {
         this.propertyListener = IndexerListener.CreateListener(this, this.source, this.index, this.intIndexer, this.indexer, this.listenToChanges);
     }
     if (this.listenToChanges)
     {
         this.collectionChangedListener = WeakCollectionChangedListener.CreateIfNecessary(this.source, this);
     }
     return true;
 }