aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/BaseEntity.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/Entities/BaseEntity.cs')
-rw-r--r--MediaBrowser.Controller/Entities/BaseEntity.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseEntity.cs b/MediaBrowser.Controller/Entities/BaseEntity.cs
index 53b42da01..7f0ea12b8 100644
--- a/MediaBrowser.Controller/Entities/BaseEntity.cs
+++ b/MediaBrowser.Controller/Entities/BaseEntity.cs
@@ -1,4 +1,8 @@
using System;
+using System.Collections.Generic;
+using System.Linq;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.IO;
namespace MediaBrowser.Controller.Entities
{
@@ -11,6 +15,10 @@ namespace MediaBrowser.Controller.Entities
public Guid Id { get; set; }
+ public string Path { get; set; }
+
+ public Folder Parent { get; set; }
+
public string PrimaryImagePath { get; set; }
public DateTime DateCreated { get; set; }
@@ -21,5 +29,45 @@ namespace MediaBrowser.Controller.Entities
{
return Name;
}
+
+ protected ItemResolveEventArgs _resolveArgs;
+ /// <summary>
+ /// We attach these to the item so that we only ever have to hit the file system once
+ /// (this includes the children of the containing folder)
+ /// Use ResolveArgs.FileSystemChildren to check for the existence of files instead of File.Exists
+ /// </summary>
+ public ItemResolveEventArgs ResolveArgs
+ {
+ get
+ {
+ if (_resolveArgs == null)
+ {
+ _resolveArgs = new ItemResolveEventArgs()
+ {
+ FileInfo = FileData.GetFileData(this.Path),
+ Parent = this.Parent,
+ Cancel = false,
+ Path = this.Path
+ };
+ _resolveArgs = FileSystemHelper.FilterChildFileSystemEntries(_resolveArgs, (this.Parent != null && this.Parent.IsRoot));
+ }
+ return _resolveArgs;
+ }
+ set
+ {
+ _resolveArgs = value;
+ }
+ }
+
+ /// <summary>
+ /// Refresh metadata on us by execution our provider chain
+ /// </summary>
+ /// <returns>true if a provider reports we changed</returns>
+ public bool RefreshMetadata()
+ {
+ Kernel.Instance.ExecuteMetadataProviders(this).ConfigureAwait(false);
+ return true;
+ }
+
}
}