コード例 #1
0
 public static void RemoveAll <T, T2>(this IReactiveList <T> list, Predicate <T2> predicate) where T2 : T
 {
     if (list == null)
     {
         throw new ArgumentNullException(nameof(list));
     }
     if (predicate == null)
     {
         throw new ArgumentNullException(nameof(predicate));
     }
     list.RemoveAll(list.Where(x => predicate((T2)x)).ToArray());
 }
コード例 #2
0
        /*        public static void RemoveAllLocked<T, T2>(this ReactiveList<T> list, IEnumerable<T2> other) where T2 : T
         * {
         *  if (list == null) throw new ArgumentNullException(nameof(list));
         *  if (other == null) throw new ArgumentNullException(nameof(other));
         *  lock (list)
         *      list.RemoveAll(other);
         * }*/

        public static void RemoveAllLocked <T>(this IReactiveList <T> list, Predicate <T> predicate)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }
            lock (list)
                list.RemoveAll(list.Where(x => predicate(x)).ToArray());
        }
コード例 #3
0
 void SetupCollectionItems <T>(IReactiveList <T> src, IReactiveList <IHierarchicalLibraryItem> dst,
                               Func <T, bool> predicate = null) where T : Collection
 {
     lock (src) {
         var srcF = predicate == null ? src : src.Where(predicate);
         lock (dst)
             dst.AddRange(srcF.Select(CreateCustomModSet));
         _disposables.Add(src.TrackChanges(
                              x => dst.AddLocked(CreateCustomModSet(x)),
                              x => {
             lock (CollectionsGroup.Children)
                 dst.RemoveLocked(GetCollection(x));
         },
                              reset => {
             lock (dst) {
                 lock (CollectionsGroup.Children)
                     dst.RemoveAll(GetCollections().ToArray());
                 dst.AddRange(reset.Select(CreateCustomModSet));
             }
         }, predicate));
     }
 }