aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/BaseItem.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/Entities/BaseItem.cs')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs35
1 files changed, 11 insertions, 24 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 22efd3fba..3313f45fd 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -491,6 +491,17 @@ namespace MediaBrowser.Controller.Entities
}
}
+ /// <summary>
+ /// Finds a parent of a given type
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <returns>``0.</returns>
+ public T FindParent<T>()
+ where T : Folder
+ {
+ return Parents.OfType<T>().FirstOrDefault();
+ }
+
[IgnoreDataMember]
public virtual BaseItem DisplayParent
{
@@ -1458,30 +1469,6 @@ namespace MediaBrowser.Controller.Entities
}
/// <summary>
- /// Finds a parent of a given type
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <returns>``0.</returns>
- public T FindParent<T>()
- where T : Folder
- {
- var parent = Parent;
-
- while (parent != null)
- {
- var result = parent as T;
- if (result != null)
- {
- return result;
- }
-
- parent = parent.Parent;
- }
-
- return null;
- }
-
- /// <summary>
/// Gets an image
/// </summary>
/// <param name="type">The type.</param>