public MultiCollectionGroup(CollectionWithItems collectionWithItems) { if (collectionWithItems.UseCustomOrder) { if (collectionWithItems.MediaItems.Count > 0) { First = collectionWithItems.MediaItems.Head(); Additional = collectionWithItems.MediaItems.Tail().ToList(); } else { throw new InvalidOperationException("Collection has no items"); } } else { switch (collectionWithItems.PlaybackOrder) { case PlaybackOrder.Chronological: var sortedItems = collectionWithItems.MediaItems.OrderBy(identity, new ChronologicalMediaComparer()) .ToList(); First = sortedItems.Head(); Additional = sortedItems.Tail().ToList(); break; default: throw new NotSupportedException( $"Unsupported MultiCollection PlaybackOrder: {collectionWithItems.PlaybackOrder}"); } } }
private static IList <Option <MediaItem> > OrderItems(CollectionWithItems collectionWithItems) { if (collectionWithItems.UseCustomOrder) { return(collectionWithItems.MediaItems.Map(Some).ToList()); } return(collectionWithItems.MediaItems .OrderBy(identity, new ChronologicalMediaComparer()) .Map(Some) .ToList()); }