/// <summary> /// Initializes a new instance of the <see cref="BindingListToBindableCollectionAdapter<TElement>"/> class. /// </summary> /// <param name="sourceCollection">The source collection.</param> /// <param name="dispatcher">The dispatcher.</param> public BindingListToBindableCollectionAdapter(IEnumerable sourceCollection, IDispatcher dispatcher) : base(sourceCollection, dispatcher) { var observable = (IBindingList)sourceCollection; observable.ListChanged += Weak.Event <ListChangedEventArgs>((sender, e) => Dispatcher.Dispatch(() => SourceCollection_ListChanged(sender, e))).KeepAlive(InstanceLifetime).HandlerProxy.Handler; }
/// <summary> /// Initializes a new instance of the <see cref="Iterator<TSource, TResult>"/> class. /// </summary> protected Iterator(IBindableCollection <TSource> sourceCollection, IDispatcher dispatcher) : base(dispatcher) { _resultCollection = new BindableCollection <TResult>(dispatcher); _resultCollection.CollectionChanged += ((sender, e) => OnCollectionChanged(e)); _sourceCollection = sourceCollection; _sourceCollection.CollectionChanged += Weak.Event <NotifyCollectionChangedEventArgs>((sender, e) => Dispatcher.Dispatch(() => ReactToCollectionChanged(e))).KeepAlive(InstanceLifetime).HandlerProxy.Handler; }
public ObservableCollectionToBindableCollectionAdapter(IEnumerable sourceCollection, IDispatcher dispatcher) : base(sourceCollection, dispatcher) { var observable = sourceCollection as INotifyCollectionChanged; if (observable != null) { // TODO observable.CollectionChanged += Weak.Event <NotifyCollectionChangedEventArgs>((sender, e) => Dispatcher.Dispatch(() => OnCollectionChanged(e))).KeepAlive(InstanceLifetime).HandlerProxy.Handler; } }
public ObservableCollectionToBindableCollectionAdapter(IEnumerable sourceCollection, IDispatcher dispatcher) : base(sourceCollection, dispatcher) { if (sourceCollection is INotifyCollectionChanged notifyCollectionChanged) { notifyCollectionChanged.CollectionChanged += Weak.Event(delegate(object sender, NotifyCollectionChangedEventArgs e) { var observableCollectionToBindableCollectionAdapter = this; Dispatcher.Dispatch(delegate { observableCollectionToBindableCollectionAdapter.OnCollectionChanged(e); }); }).KeepAlive(InstanceLifetime).HandlerProxy.Handler; } }
public BindingListToBindableCollectionAdapter(IEnumerable sourceCollection, IDispatcher dispatcher) : base(sourceCollection, dispatcher) { var bindingList = (IBindingList)sourceCollection; var bindingList2 = bindingList; EventHandler <ListChangedEventArgs> eventHandler = delegate(object sender, ListChangedEventArgs e) { var bindingListToBindableCollectionAdapter = this; Dispatcher.Dispatch(delegate { bindingListToBindableCollectionAdapter.SourceCollection_ListChanged(sender, e); }); }; bindingList2.ListChanged += Weak.Event(eventHandler).KeepAlive(InstanceLifetime).HandlerProxy.Handler; }
/// <summary> /// Initializes a new instance of the <see cref="Aggregator<TSource, TResult>"/> class. /// </summary> /// <param name="sourceCollection">The source collection.</param> /// <param name="dispatcher">The dispatcher.</param> protected Aggregator(IBindableCollection <TSource> sourceCollection, IDispatcher dispatcher) : base(dispatcher) { _sourceCollection = sourceCollection; _sourceCollection.CollectionChanged += Weak.Event <NotifyCollectionChangedEventArgs>((sender, e) => Dispatcher.Dispatch(Refresh)).KeepAlive(InstanceLifetime).HandlerProxy.Handler; }
/// <summary> /// Initializes a new instance of the <see cref="Operator<TSource, TResult>"/> class. /// </summary> /// <param name="dispatcher">The dispatcher.</param> /// <param name="source">The source.</param> protected Operator(IBindable <TSource> source, IDispatcher dispatcher) : base(dispatcher) { _source = source; _source.PropertyChanged += Weak.Event <PropertyChangedEventArgs>((sender, e) => Dispatcher.Dispatch(Refresh)).KeepAlive(InstanceLifetime).HandlerProxy.Handler; }