You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Controller/Resolvers/FolderResolver.cs

46 lines
1.3 KiB

using System.ComponentModel.Composition;
13 years ago
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Xml;
using MediaBrowser.Model.Entities;
13 years ago
namespace MediaBrowser.Controller.Resolvers
{
[Export(typeof(IBaseItemResolver))]
13 years ago
public class FolderResolver : BaseFolderResolver<Folder>
{
protected override Folder Resolve(ItemResolveEventArgs args)
{
if (args.IsFolder)
{
return new Folder();
}
return null;
}
}
public abstract class BaseFolderResolver<T> : BaseItemResolver<T>
where T : Folder, new ()
{
protected override void SetItemValues(T item, ItemResolveEventArgs args)
{
base.SetItemValues(item, args);
item.IsRoot = args.Parent == null;
// Read data from folder.xml, if it exists
13 years ago
PopulateFolderMetadata(item, args);
}
private void PopulateFolderMetadata(Folder folder, ItemResolveEventArgs args)
{
var metadataFile = args.GetFileByName("folder.xml");
if (metadataFile.HasValue)
{
new FolderXmlParser().Fetch(folder, metadataFile.Value.Key);
}
}
}
}