2012-08-18 08:22:54 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Model.Entities
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2012-08-18 19:38:27 +00:00
|
|
|
|
/// Since BaseItem and DTOBaseItem both have ProviderIds, this interface helps avoid code repition by using extension methods
|
2012-08-18 08:22:54 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
public interface IHasProviderIds
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string> ProviderIds { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-11 18:20:12 +00:00
|
|
|
|
public static class ProviderIdsExtensions
|
2012-08-18 08:22:54 +00:00
|
|
|
|
{
|
|
|
|
|
/// <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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|