Пример #1
0
 private void IncrementallyChangeList <T>(ObservableCollectionWorkaround <T> oldList, IList <T> newList, IComparer <T> comparer)
 {
     if (newList.Count == 0)
     {
         oldList.Clear();
     }
     else
     {
         IList <T> list;
         if (oldList.Count == 0)
         {
             list = newList;
         }
         else
         {
             HashSet <T> oldItemsSet = new HashSet <T>((IEnumerable <T>)oldList);
             list = (IList <T>)Enumerable.ToList <T>(Enumerable.Where <T>((IEnumerable <T>)newList, (Func <T, bool>)(item => !oldItemsSet.Contains(item))));
             oldItemsSet.ExceptWith((IEnumerable <T>)newList);
             EnumerableExtensions.ForEach <T>((IEnumerable <T>)oldItemsSet, (Action <T>)(item => ((Collection <T>)oldList).Remove(item)));
         }
         foreach (T obj in (IEnumerable <T>)list)
         {
             int index = oldList.BinarySearch(obj, comparer);
             if (index < 0)
             {
                 index = ~index;
             }
             oldList.Insert(index, obj);
         }
     }
 }
 protected override ObservableCollectionWorkaround <LocalResourceModel> RecalculateLocalResources(ObservableCollectionWorkaround <LocalResourceModel> currentResources)
 {
     this.documentResourcesChangeStamp = this.DesignerContext.ResourceManager.ResourceChangeStamp;
     if (this.DesignerContext.SelectionManager.SelectedNodes != null && this.DesignerContext.SelectionManager.SelectedNodes.Length != 0)
     {
         return(this.ProvideLocalResources(new List <ResourceContainer>(this.DesignerContext.ResourceManager.ActiveResourceContainers)));
     }
     if (currentResources == null)
     {
         return(new ObservableCollectionWorkaround <LocalResourceModel>());
     }
     currentResources.Clear();
     return(currentResources);
 }