From 2d8152f36ad8ecc5674cfb25ad328d3e671a22de Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 26 Sep 2013 17:20:26 -0400 Subject: mono progress - able to start app --- MediaBrowser.Controller/Entities/Folder.cs | 29 ++++++++++++++++------ .../Notifications/INotificationsRepository.cs | 6 +++++ .../Persistence/IItemRepository.cs | 1 - .../Persistence/IUserRepository.cs | 2 +- 4 files changed, 29 insertions(+), 9 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 1015a3021a..6f5bc3e3be 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -980,7 +980,7 @@ namespace MediaBrowser.Controller.Entities var initialCount = _children.Count; var list = new List(initialCount); - AddChildrenToList(user, includeLinkedChildren, list, false); + AddChildrenToList(user, includeLinkedChildren, list, false, null); return list; } @@ -992,7 +992,9 @@ namespace MediaBrowser.Controller.Entities /// if set to true [include linked children]. /// The list. /// if set to true [recursive]. - private bool AddChildrenToList(User user, bool includeLinkedChildren, List list, bool recursive) + /// The filter. + /// true if XXXX, false otherwise + private bool AddChildrenToList(User user, bool includeLinkedChildren, List list, bool recursive, Func filter) { var hasLinkedChildren = false; @@ -1000,7 +1002,10 @@ namespace MediaBrowser.Controller.Entities { if (child.IsVisible(user)) { - list.Add(child); + if (filter == null || filter(child)) + { + list.Add(child); + } } if (recursive) @@ -1009,7 +1014,7 @@ namespace MediaBrowser.Controller.Entities if (folder != null) { - if (folder.AddChildrenToList(user, includeLinkedChildren, list, true)) + if (folder.AddChildrenToList(user, includeLinkedChildren, list, true, filter)) { hasLinkedChildren = true; } @@ -1021,6 +1026,11 @@ namespace MediaBrowser.Controller.Entities { foreach (var child in GetLinkedChildren()) { + if (filter != null && !filter(child)) + { + continue; + } + hasLinkedChildren = true; if (child.IsVisible(user)) @@ -1042,6 +1052,11 @@ namespace MediaBrowser.Controller.Entities /// IEnumerable{BaseItem}. /// public IEnumerable GetRecursiveChildren(User user, bool includeLinkedChildren = true) + { + return GetRecursiveChildren(user, null, true); + } + + public IEnumerable GetRecursiveChildren(User user, Func filter, bool includeLinkedChildren = true) { if (user == null) { @@ -1051,10 +1066,10 @@ namespace MediaBrowser.Controller.Entities var initialCount = _lastRecursiveCount == 0 ? _children.Count : _lastRecursiveCount; var list = new List(initialCount); - var hasLinkedChildren = AddChildrenToList(user, includeLinkedChildren, list, true); + var hasLinkedChildren = AddChildrenToList(user, includeLinkedChildren, list, true, null); _lastRecursiveCount = list.Count; - + if (includeLinkedChildren && hasLinkedChildren) { list = list.Distinct().ToList(); @@ -1062,7 +1077,7 @@ namespace MediaBrowser.Controller.Entities return list; } - + /// /// Gets the linked children. /// diff --git a/MediaBrowser.Controller/Notifications/INotificationsRepository.cs b/MediaBrowser.Controller/Notifications/INotificationsRepository.cs index 8790b54f46..7a4b69b528 100644 --- a/MediaBrowser.Controller/Notifications/INotificationsRepository.cs +++ b/MediaBrowser.Controller/Notifications/INotificationsRepository.cs @@ -25,6 +25,12 @@ namespace MediaBrowser.Controller.Notifications /// event EventHandler NotificationsMarkedRead; + /// + /// Opens the connection to the repository + /// + /// Task. + Task Initialize(); + /// /// Gets the notifications. /// diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index 8960b5dfb1..e04f256053 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/MediaBrowser.Controller/Persistence/IUserRepository.cs b/MediaBrowser.Controller/Persistence/IUserRepository.cs index 49c418c303..0241b8c034 100644 --- a/MediaBrowser.Controller/Persistence/IUserRepository.cs +++ b/MediaBrowser.Controller/Persistence/IUserRepository.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Persistence /// Opens the connection to the repository /// /// Task. - void Initialize(); + Task Initialize(); /// /// Deletes the user. -- cgit v1.2.3