2021-05-06 22:39:20 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2019-01-13 20:01:16 +00:00
|
|
|
using MediaBrowser.Controller.Entities;
|
2018-12-27 23:27:57 +00:00
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Resolvers
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Class ItemResolver.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
2021-06-06 15:16:41 +00:00
|
|
|
/// <typeparam name="T">The type of BaseItem.</typeparam>
|
2018-12-27 23:27:57 +00:00
|
|
|
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;
|
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Resolves the specified args.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="args">The args.</param>
|
|
|
|
/// <returns>`0.</returns>
|
2022-10-11 21:37:29 +00:00
|
|
|
protected internal virtual T Resolve(ItemResolveArgs args)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Sets initial values on the newly resolved item.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </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>
|
2022-10-11 21:37:29 +00:00
|
|
|
public BaseItem ResolvePath(ItemResolveArgs args)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
var item = Resolve(args);
|
|
|
|
|
2022-12-05 14:01:13 +00:00
|
|
|
if (item is not null)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
SetInitialItemValues(item, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|