using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using System.ComponentModel.Composition;
namespace MediaBrowser.Controller.Resolvers
{
///
/// Class FolderResolver
///
[Export(typeof(IBaseItemResolver))]
public class FolderResolver : BaseFolderResolver
{
///
/// Gets the priority.
///
/// The priority.
public override ResolverPriority Priority
{
get { return ResolverPriority.Last; }
}
///
/// Resolves the specified args.
///
/// The args.
/// Folder.
protected override Folder Resolve(ItemResolveArgs args)
{
if (args.IsDirectory)
{
if (args.IsPhysicalRoot)
{
return new AggregateFolder();
}
if (args.IsRoot)
{
return new UserRootFolder(); //if we got here and still a root - must be user root
}
if (args.IsVf)
{
return new CollectionFolder();
}
return new Folder();
}
return null;
}
}
///
/// Class BaseFolderResolver
///
/// The type of the T item type.
public abstract class BaseFolderResolver : BaseItemResolver
where TItemType : Folder, new()
{
///
/// Sets the initial item values.
///
/// The item.
/// The args.
protected override void SetInitialItemValues(TItemType item, ItemResolveArgs args)
{
base.SetInitialItemValues(item, args);
item.IsRoot = args.Parent == null;
item.IsPhysicalRoot = args.IsPhysicalRoot;
}
}
}