mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-27 11:14:47 +03:00
Added a completely separate DTOBaseItem to remove the ApiBaseItemWrapper mess and shrink json output size.
This commit is contained in:
parent
f32f000298
commit
7835d690a1
57
MediaBrowser.Model/Entities/IHasProviderIds.cs
Normal file
57
MediaBrowser.Model/Entities/IHasProviderIds.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Since BaseItem and DTOBaseItem both have ProviderIds, this interface helps avoid code repition using extension methods
|
||||
/// </summary>
|
||||
public interface IHasProviderIds
|
||||
{
|
||||
Dictionary<string, string> ProviderIds { get; set; }
|
||||
}
|
||||
|
||||
public static class IProviderIdsExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a provider id
|
||||
/// </summary>
|
||||
public static string GetProviderId(this IHasProviderIds instance, MetadataProviders provider)
|
||||
{
|
||||
return instance.GetProviderId(provider.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a provider id
|
||||
/// </summary>
|
||||
public static string GetProviderId(this IHasProviderIds instance, string name)
|
||||
{
|
||||
if (instance.ProviderIds == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return instance.ProviderIds[name];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a provider id
|
||||
/// </summary>
|
||||
public static void SetProviderId(this IHasProviderIds instance, string name, string value)
|
||||
{
|
||||
if (instance.ProviderIds == null)
|
||||
{
|
||||
instance.ProviderIds = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
instance.ProviderIds[name] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a provider id
|
||||
/// </summary>
|
||||
public static void SetProviderId(this IHasProviderIds instance, MetadataProviders provider, string value)
|
||||
{
|
||||
instance.SetProviderId(provider.ToString(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user