protected void RefreshInternalView(bool resetStatus) { if (this.DataView != null) { if (this.DataView.BatchDataProvider != null) { this.DataView.BatchDataProvider.StatusChanged -= this.BatchProvider_StatusChanged; this.DataView.BatchDataProvider.Dispose(); } this.DataView.CollectionChanged -= this.DataView_CollectionChanged; this.DataView.ItemPropertyChanged -= this.DataView_ItemPropertyChanged; this.DataView.Dispose(); } if (resetStatus) { this.ResetStatus(); } this.DataView = DataSourceViewFacotry.CreateDataSourceView(this.ItemsSource ?? Enumerable.Empty <object>()); if (this.DataView.BatchDataProvider != null) { this.DataView.BatchDataProvider.StatusChanged += this.BatchProvider_StatusChanged; } this.DataView.CollectionChanged += this.DataView_CollectionChanged; this.DataView.ItemPropertyChanged += this.DataView_ItemPropertyChanged; }
public void Count_WhenItemsSourceIsEnumerable_ReturnsTheCountOfAllRows() { var data = Order.GetSmallData(); var sourceView = DataSourceViewFacotry.CreateDataSourceView(data); var expectedNumberOfRows = data.Count; var actualNumberOfRows = sourceView.InternalList.Count; Assert.AreEqual(expectedNumberOfRows, actualNumberOfRows); }
public void Indexer_WhenItemsSourceIsEnumerable_WhenCorrectIndexIsSpecified_ReturnsTheCorrectItem() { var data = Order.GetSmallData(); var sourceView = DataSourceViewFacotry.CreateDataSourceView(data); var expectedItem = data[2]; var actualItem = sourceView.InternalList[2]; Assert.AreSame(expectedItem, actualItem); }
public void OriginalCollectionIsCopied_WhenItemsSourceIsEnumerable_AndModificationsToTheOriginalCollectionDoNotChangeTheInternalCollectionOfTheView() { var data = Order.GetSmallData(); var sourceView = DataSourceViewFacotry.CreateDataSourceView(data); var expectedItemCount = data.Count; data.Add(new Order()); var actualItemCount = sourceView.InternalList.Count; Assert.AreEqual(expectedItemCount, actualItemCount); }
private void UpdateSource(object newSource) { if (this.sourceView != null) { this.sourceView.CollectionChanging -= this.SourceCollectionChanging; this.sourceView.CollectionChanged -= this.SourceCollectionChanged; } this.sourceView = DataSourceViewFacotry.CreateDataSourceView(newSource ?? Enumerable.Empty <object>()); this.sourceView.CollectionChanging += this.SourceCollectionChanging; this.sourceView.CollectionChanged += this.SourceCollectionChanged; }