aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-09-26 17:20:26 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-09-26 17:20:26 -0400
commit2d8152f36ad8ecc5674cfb25ad328d3e671a22de (patch)
tree3adc6e475d7375141af11acb80714114a5fab931 /MediaBrowser.Controller
parent2d0cc66e6bea278b7be5078130f55fc05ce756ce (diff)
mono progress - able to start app
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/Folder.cs29
-rw-r--r--MediaBrowser.Controller/Notifications/INotificationsRepository.cs6
-rw-r--r--MediaBrowser.Controller/Persistence/IItemRepository.cs1
-rw-r--r--MediaBrowser.Controller/Persistence/IUserRepository.cs2
4 files changed, 29 insertions, 9 deletions
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index 1015a3021..6f5bc3e3b 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<BaseItem>(initialCount);
- AddChildrenToList(user, includeLinkedChildren, list, false);
+ AddChildrenToList(user, includeLinkedChildren, list, false, null);
return list;
}
@@ -992,7 +992,9 @@ namespace MediaBrowser.Controller.Entities
/// <param name="includeLinkedChildren">if set to <c>true</c> [include linked children].</param>
/// <param name="list">The list.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
- private bool AddChildrenToList(User user, bool includeLinkedChildren, List<BaseItem> list, bool recursive)
+ /// <param name="filter">The filter.</param>
+ /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
+ private bool AddChildrenToList(User user, bool includeLinkedChildren, List<BaseItem> list, bool recursive, Func<BaseItem,bool> 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))
@@ -1043,6 +1053,11 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="System.ArgumentNullException"></exception>
public IEnumerable<BaseItem> GetRecursiveChildren(User user, bool includeLinkedChildren = true)
{
+ return GetRecursiveChildren(user, null, true);
+ }
+
+ public IEnumerable<BaseItem> GetRecursiveChildren(User user, Func<BaseItem,bool> filter, bool includeLinkedChildren = true)
+ {
if (user == null)
{
throw new ArgumentNullException();
@@ -1051,10 +1066,10 @@ namespace MediaBrowser.Controller.Entities
var initialCount = _lastRecursiveCount == 0 ? _children.Count : _lastRecursiveCount;
var list = new List<BaseItem>(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;
}
-
+
/// <summary>
/// Gets the linked children.
/// </summary>
diff --git a/MediaBrowser.Controller/Notifications/INotificationsRepository.cs b/MediaBrowser.Controller/Notifications/INotificationsRepository.cs
index 8790b54f4..7a4b69b52 100644
--- a/MediaBrowser.Controller/Notifications/INotificationsRepository.cs
+++ b/MediaBrowser.Controller/Notifications/INotificationsRepository.cs
@@ -26,6 +26,12 @@ namespace MediaBrowser.Controller.Notifications
event EventHandler<NotificationReadEventArgs> NotificationsMarkedRead;
/// <summary>
+ /// Opens the connection to the repository
+ /// </summary>
+ /// <returns>Task.</returns>
+ Task Initialize();
+
+ /// <summary>
/// Gets the notifications.
/// </summary>
/// <param name="query">The query.</param>
diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs
index 8960b5dfb..e04f25605 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 49c418c30..0241b8c03 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
/// </summary>
/// <returns>Task.</returns>
- void Initialize();
+ Task Initialize();
/// <summary>
/// Deletes the user.