Exemple #1
0
        private static bool DetachCollectionAndView(CollectionView view)
        {
            // make sure view implements INotifyCollectionChanged
            INotifyCollectionChanged iCollectionChanged = view.SourceCollection as INotifyCollectionChanged;

            if (iCollectionChanged == null)
            {
                return(false);
            }

            // Get the method that subscribes to OnCollectionChanged
            MethodInfo onCollectionChanged = view.GetType().GetMethod("OnCollectionChanged",
                                                                      BindingFlags.NonPublic | BindingFlags.Instance, null,
                                                                      new Type[] { typeof(object), typeof(NotifyCollectionChangedEventArgs) },
                                                                      null
                                                                      );
            NotifyCollectionChangedEventHandler handler = Delegate.CreateDelegate(typeof(NotifyCollectionChangedEventHandler),
                                                                                  view,
                                                                                  onCollectionChanged
                                                                                  ) as NotifyCollectionChangedEventHandler;

            // remove collection changed handler
            _tweets.CollectionChanged -= handler;

            return(true);
        }
Exemple #2
0
        private void ValidateViewType(CollectionView cv, Type collectionViewType)
        {
            if (collectionViewType != null)
            {
                // If the view contained in the ViewTable is a proxy of another
                // view, then what we really want to compare is the type of that
                // other view.
                CollectionViewProxy cvp = cv as CollectionViewProxy;
                Type cachedViewType     = (cvp == null) ? cv.GetType() : cvp.ProxiedView.GetType();

                if (cachedViewType != collectionViewType)
                {
                    throw new ArgumentException(SR.Get(SRID.CollectionView_NameTypeDuplicity, collectionViewType, cachedViewType));
                }
            }
        }
 // Token: 0x06007701 RID: 30465 RVA: 0x0022024C File Offset: 0x0021E44C
 private void ValidateViewType(CollectionView cv, Type collectionViewType)
 {
     if (collectionViewType != null)
     {
         CollectionViewProxy collectionViewProxy = cv as CollectionViewProxy;
         Type type = (collectionViewProxy == null) ? cv.GetType() : collectionViewProxy.ProxiedView.GetType();
         if (type != collectionViewType)
         {
             throw new ArgumentException(SR.Get("CollectionView_NameTypeDuplicity", new object[]
             {
                 collectionViewType,
                 type
             }));
         }
     }
 }
Exemple #4
0
        private void ValidateViewType(CollectionView cv, Type collectionViewType)
        {
            if (collectionViewType != null)
            { 
                // If the view contained in the ViewTable is a proxy of another
                // view, then what we really want to compare is the type of that 
                // other view. 
                CollectionViewProxy cvp = cv as CollectionViewProxy;
                Type cachedViewType = (cvp == null) ? cv.GetType() : cvp.ProxiedView.GetType(); 

                if (cachedViewType != collectionViewType)
                    throw new ArgumentException(SR.Get(SRID.CollectionView_NameTypeDuplicity, collectionViewType, cachedViewType));
            } 
        }