public static BindingList <T> AttachTo <T>(this BindingList <T> source, BindingList <T> target) { source.ForEachNewOrExistingItem(target.Add); source.ForEachItemDeleted(k => target.Remove(k)); return(source); }
public static BindingList <T> AttachTo <T>(this BindingList <T> e, Func <IAddChild> GetContainer) where T : ISupportsContainer { e.ForEachNewOrExistingItem( k => { var c = GetContainer(); if (c != null) { k.AttachContainerTo(c); } } ); e.ForEachItemDeleted( k => { var c = GetContainer(); if (c != null) { k.OrphanizeContainer(); } } ); return(e); }
public static BindingList <T> AttachTo <T>(this BindingList <T> e, IAddChild c) where T : ISupportsContainer { e.ForEachNewOrExistingItem(k => k.AttachContainerTo(c)); e.ForEachItemDeleted(k => k.OrphanizeContainer()); return(e); }
public static BindingList <T> AttachTo <T, K>(this BindingList <T> e, Func <T, K> selector, IAddChild c) where K : ISupportsContainer { e.ForEachNewOrExistingItem(k => selector(k).AttachContainerTo(c)); e.ForEachItemDeleted(k => selector(k).OrphanizeContainer()); return(e); }
public static BindingList <T> AttachToFrameworkElement <T>(this BindingList <T> e, IAddChild c) where T : FrameworkElement { e.ForEachNewOrExistingItem(k => k.AttachTo(c)); e.ForEachItemDeleted(k => k.Orphanize()); return(e); }
public static void MirrorTo <T>(this BindingList <T> source, BindingList <T> mirror) { // gee, what an overkill :) source.ForEachNewOrExistingItem( k => { if (!mirror.Contains(k)) { mirror.Add(k); } } ); source.ForEachItemDeleted( k => { if (!mirror.Contains(k)) { mirror.Remove(k); } } ); mirror.ForEachNewOrExistingItem( k => { if (!source.Contains(k)) { source.Add(k); } } ); mirror.ForEachItemDeleted( k => { if (!source.Contains(k)) { source.Remove(k); } } ); }
public static BindingList <T> ForEachNewOrExistingItem <T>(this BindingList <T> source, Action <T, int, Action <Action <Action> > > HandlerWithDelayedWork) { var LazyLoad = new FutureStream(); var LazyLoadInitialize = LazyLoad.Continue( SignalNext => { SignalNext(); } ); LazyLoadInitialize(); return(source.ForEachNewOrExistingItem( (value, index) => { HandlerWithDelayedWork(value, index, LazyTask => LazyLoad.Continue(LazyTask)); } )); }