Example #1
0
        ToDiffableDataSourceSnapshot <TSection, TItem>(this Dictionary <TSection, List <TItem> > dict)
        {
            var snapshot = new NSDiffableDataSourceSnapshot <IdentifierType <TSection>, IdentifierType <TItem> >();

            foreach (var kvp in dict)
            {
                var section = IdentifierType.For(kvp.Key);
                var items   = kvp.Value.Select(IdentifierType.For).ToArray();

                snapshot.AppendSections(new[] { section });
                snapshot.AppendItems(items);
            }

            return(snapshot);
        }
Example #2
0
        ToDiffableDataSourceSnapshot <TSection, TSectionIdentifier, TItem, TItemIdentifier>(
            this IEnumerable <TSection> sections, Func <TSection, TSectionIdentifier> getSectionIdentifier,
            Func <TSection, IEnumerable <TItem> > getItems, Func <TItem, TItemIdentifier> getItemIdentifier)
        {
            var snapshot = new NSDiffableDataSourceSnapshot <IdentifierType <TSection>, IdentifierType <TItem> >();

            foreach (var section in sections)
            {
                var items = getItems(section);

                var sectionIdentifier = IdentifierType.For(section, getSectionIdentifier);
                var itemIdentifiers   = items.Select(item => IdentifierType.For(item, getItemIdentifier)).ToArray();

                snapshot.AppendSections(new[] { sectionIdentifier });
                snapshot.AppendItems(itemIdentifiers);
            }

            return(snapshot);
        }
Example #3
0
        ToDiffableDataSourceSnapshot <TObject, TSection, TItem>(
            this TObject obj,
            Func <TObject, IEnumerable <TSection> > getSections,
            Func <TSection, IEnumerable <TItem> > getItems)
        {
            var snapshot = new NSDiffableDataSourceSnapshot <IdentifierType <TSection>, IdentifierType <TItem> >();

            foreach (var section in getSections(obj))
            {
                var items = getItems(section);

                var sectionIdentifier = IdentifierType.For(section);
                var itemIdentifiers   = items.Select(IdentifierType.For).ToArray();

                snapshot.AppendSections(new[] { sectionIdentifier });
                snapshot.AppendItems(itemIdentifiers);
            }

            return(snapshot);
        }