From 20810eedbe0c4fdd9f1ea443ea1d196697e5d2e1 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 2 Mar 2021 09:35:51 +0100 Subject: Merge pull request #5339 from Bond-009/hasproviderids Revert breaking change to HasProviderId (cherry picked from commit e858e5f0b8ee548eee08aa69158ba1aa9bfcb1f9) Signed-off-by: Joshua M. Boniface --- .../Entities/ProviderIdsExtensions.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'MediaBrowser.Model/Entities') diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs index 4aff6e3a4f..16e1d49c76 100644 --- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs +++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs @@ -9,6 +9,33 @@ namespace MediaBrowser.Model.Entities /// public static class ProviderIdsExtensions { + /// + /// Checks if this instance has an id for the given provider. + /// + /// The instance. + /// The of the provider name. + /// true if a provider id with the given name was found; otherwise false. + public static bool HasProviderId(this IHasProviderIds instance, string name) + { + if (instance == null) + { + throw new ArgumentNullException(nameof(instance)); + } + + return instance.ProviderIds?.ContainsKey(name) ?? false; + } + + /// + /// Checks if this instance has an id for the given provider. + /// + /// The instance. + /// The provider. + /// true if a provider id with the given name was found; otherwise false. + public static bool HasProviderId(this IHasProviderIds instance, MetadataProvider provider) + { + return instance.HasProviderId(provider.ToString()); + } + /// /// Gets a provider id. /// -- cgit v1.2.3