aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Library/ItemResolveArgs.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/Library/ItemResolveArgs.cs')
-rw-r--r--MediaBrowser.Controller/Library/ItemResolveArgs.cs62
1 files changed, 33 insertions, 29 deletions
diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs
index c1fcdc9fe..4fa07421c 100644
--- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs
+++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs
@@ -154,6 +154,28 @@ namespace MediaBrowser.Controller.Library
/// <value>The additional locations.</value>
private List<string> AdditionalLocations { get; set; }
+ public bool HasParent<T>()
+ where T : Folder
+ {
+ var parent = Parent;
+
+ if (parent != null)
+ {
+ var item = parent as T;
+
+ // Just in case the user decided to nest episodes.
+ // Not officially supported but in some cases we can handle it.
+ if (item == null)
+ {
+ item = parent.Parents.OfType<T>().FirstOrDefault();
+ }
+
+ return item != null;
+
+ }
+ return false;
+ }
+
/// <summary>
/// Adds the additional location.
/// </summary>
@@ -165,7 +187,7 @@ namespace MediaBrowser.Controller.Library
{
throw new ArgumentNullException();
}
-
+
if (AdditionalLocations == null)
{
AdditionalLocations = new List<string>();
@@ -182,7 +204,7 @@ namespace MediaBrowser.Controller.Library
{
get
{
- var paths = string.IsNullOrWhiteSpace(Path) ? new string[] {} : new[] {Path};
+ var paths = string.IsNullOrWhiteSpace(Path) ? new string[] { } : new[] { Path };
return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations);
}
}
@@ -199,7 +221,7 @@ namespace MediaBrowser.Controller.Library
{
throw new ArgumentNullException();
}
-
+
return GetFileSystemEntryByPath(System.IO.Path.Combine(Path, name));
}
@@ -215,7 +237,7 @@ namespace MediaBrowser.Controller.Library
{
throw new ArgumentNullException();
}
-
+
if (FileSystemDictionary != null)
{
FileSystemInfo entry;
@@ -230,29 +252,18 @@ namespace MediaBrowser.Controller.Library
}
/// <summary>
- /// Gets the name of the meta file by.
+ /// Determines whether [contains meta file by name] [the specified name].
/// </summary>
/// <param name="name">The name.</param>
- /// <returns>FileSystemInfo.</returns>
- /// <exception cref="System.ArgumentNullException"></exception>
- public FileSystemInfo GetMetaFileByName(string name)
+ /// <returns><c>true</c> if [contains meta file by name] [the specified name]; otherwise, <c>false</c>.</returns>
+ public bool ContainsMetaFileByName(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException();
}
- return GetFileSystemEntryByName(name);
- }
-
- /// <summary>
- /// Determines whether [contains meta file by name] [the specified name].
- /// </summary>
- /// <param name="name">The name.</param>
- /// <returns><c>true</c> if [contains meta file by name] [the specified name]; otherwise, <c>false</c>.</returns>
- public bool ContainsMetaFileByName(string name)
- {
- return GetMetaFileByName(name) != null;
+ return GetFileSystemEntryByName(name) != null;
}
/// <summary>
@@ -265,20 +276,13 @@ namespace MediaBrowser.Controller.Library
return GetFileSystemEntryByName(name) != null;
}
- private bool _collectionTypeDiscovered;
- private string _collectionType;
-
public string GetCollectionType()
{
- if (!_collectionTypeDiscovered)
- {
- _collectionType = Parent == null ? null : _libraryManager.FindCollectionType(Parent);
- _collectionTypeDiscovered = true;
- }
-
- return _collectionType;
+ return CollectionType;
}
+ public string CollectionType { get; set; }
+
#region Equality Overrides
/// <summary>