jellyfin-server/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs

59 lines
1.6 KiB
C#
Raw Normal View History

#nullable disable
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
namespace Emby.Server.Implementations.Library.Resolvers
{
/// <summary>
2019-11-01 17:38:54 +00:00
/// Class ItemResolver.
/// </summary>
2021-08-28 22:32:50 +00:00
/// <typeparam name="T">The type of BaseItem.</typeparam>
public abstract class ItemResolver<T> : IItemResolver
where T : BaseItem, new()
{
2021-05-05 13:30:32 +00:00
/// <summary>
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
public virtual ResolverPriority Priority => ResolverPriority.First;
/// <summary>
/// Resolves the specified args.
/// </summary>
/// <param name="args">The args.</param>
/// <returns>`0.</returns>
protected virtual T Resolve(ItemResolveArgs args)
{
return null;
}
/// <summary>
/// Sets initial values on the newly resolved item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="args">The args.</param>
protected virtual void SetInitialItemValues(T item, ItemResolveArgs args)
{
}
/// <summary>
/// Resolves the path.
/// </summary>
/// <param name="args">The args.</param>
/// <returns>BaseItem.</returns>
BaseItem IItemResolver.ResolvePath(ItemResolveArgs args)
{
var item = Resolve(args);
if (item != null)
{
SetInitialItemValues(item, args);
}
return item;
}
}
}