From e677a57bf1cedc55214b0e457778311b8f1ea5ac Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 17 Jun 2013 16:35:43 -0400 Subject: switch to flat file storage --- .../Persistence/IItemRepository.cs | 74 +++++++++++++--------- 1 file changed, 43 insertions(+), 31 deletions(-) (limited to 'MediaBrowser.Controller/Persistence/IItemRepository.cs') diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index bf3bc626af..d854d0e207 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -1,9 +1,10 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Persistence { @@ -20,36 +21,6 @@ namespace MediaBrowser.Controller.Persistence /// Task. Task SaveItem(BaseItem item, CancellationToken cancellationToken); - /// - /// Gets an item - /// - /// The id. - /// BaseItem. - BaseItem GetItem(Guid id); - - /// - /// Gets children of a given Folder - /// - /// The parent. - /// IEnumerable{BaseItem}. - IEnumerable RetrieveChildren(Folder parent); - - /// - /// Retrieves the items. - /// - /// The ids. - /// IEnumerable{BaseItem}. - IEnumerable GetItems(IEnumerable ids); - - /// - /// Saves children of a given Folder - /// - /// The parent id. - /// The children. - /// The cancellation token. - /// Task. - Task SaveChildren(Guid parentId, IEnumerable children, CancellationToken cancellationToken); - /// /// Gets the critic reviews. /// @@ -72,5 +43,46 @@ namespace MediaBrowser.Controller.Persistence /// The cancellation token. /// Task. Task SaveItems(IEnumerable items, CancellationToken cancellationToken); + + /// + /// Retrieves the item. + /// + /// The id. + /// The type. + /// BaseItem. + BaseItem RetrieveItem(Guid id, Type type); + } + + /// + /// Class ItemRepositoryExtensions + /// + public static class ItemRepositoryExtensions + { + /// + /// Retrieves the item. + /// + /// + /// The repository. + /// The id. + /// ``0. + public static T RetrieveItem(this IItemRepository repository, Guid id) + where T : BaseItem, new() + { + return repository.RetrieveItem(id, typeof(T)) as T; + } + + /// + /// Retrieves the item. + /// + /// + /// The repository. + /// The id list. + /// IEnumerable{``0}. + public static IEnumerable RetrieveItems(this IItemRepository repository, IEnumerable idList) + where T : BaseItem, new() + { + return idList.Select(repository.RetrieveItem).Where(i => i != null); + } } } + -- cgit v1.2.3