Make ResolveArgs self-creating if need be

This commit is contained in:
ebr11 Eric Reed spam 2012-09-17 13:05:42 -04:00
parent 7cfa489c6e
commit 922fd3acae

View File

@ -1,5 +1,6 @@
using MediaBrowser.Model.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.IO;
using System;
using System.Collections.Generic;
using System.Linq;
@ -8,12 +9,34 @@ namespace MediaBrowser.Controller.Entities
{
public abstract class BaseItem : BaseEntity, IHasProviderIds
{
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; set; }
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;
}
}
public string SortName { get; set; }