using System.Collections.Generic; namespace MediaBrowser.Model.Entities { /// /// Since BaseItem and DTOBaseItem both have ProviderIds, this interface helps avoid code repition by using extension methods /// public interface IHasProviderIds { Dictionary ProviderIds { get; set; } } public static class IProviderIdsExtensions { /// /// Gets a provider id /// public static string GetProviderId(this IHasProviderIds instance, MetadataProviders provider) { return instance.GetProviderId(provider.ToString()); } /// /// Gets a provider id /// public static string GetProviderId(this IHasProviderIds instance, string name) { if (instance.ProviderIds == null) { return null; } return instance.ProviderIds[name]; } /// /// Sets a provider id /// public static void SetProviderId(this IHasProviderIds instance, string name, string value) { if (instance.ProviderIds == null) { instance.ProviderIds = new Dictionary(); } instance.ProviderIds[name] = value; } /// /// Sets a provider id /// public static void SetProviderId(this IHasProviderIds instance, MetadataProviders provider, string value) { instance.SetProviderId(provider.ToString(), value); } } }