private void ConfigureDataSource() { var dataSource = new UICollectionViewDiffableDataSource <NS <Section>, NS <int> >( collectionView: _collectionView, cellProvider: (collectionView, indexPath, identifier) => { var cell = (DummyCell)collectionView.DequeueReusableCell(DummyCell.Key, indexPath); cell.Configure(((NS <int>)identifier).Value.ToString()); return(cell); }); // initial data const int ItemsPerSection = 6; var snapshot = new NSDiffableDataSourceSnapshot <NS <Section>, NS <int> >(); EnumExtensions.Apply <Section>(section => { var ns = new NS <Section>(section); snapshot.AppendSections(new[] { ns }); var itemOffset = ((int)ns.Value) * ItemsPerSection; var itemUpperbound = itemOffset + ItemsPerSection; var items = Enumerable.Range(itemOffset, itemUpperbound).Select(x => new NS <int>(x)).ToArray(); snapshot.AppendItems(items); }); dataSource.ApplySnapshot(snapshot, animatingDifferences: false); }
public void Apply_NullAction_ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => { EnumExtensions.Apply <TestEnum>(null); }); }