aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Entities/IHasProviderIds.cs
diff options
context:
space:
mode:
authorLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-08-18 04:22:54 -0400
committerLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-08-18 04:22:54 -0400
commit7835d690a1ade4739171036cff335c86b5232d0e (patch)
tree0704c6bd3bf3adf3c23c67951397674ac87b5636 /MediaBrowser.Model/Entities/IHasProviderIds.cs
parentf32f000298114231f114f41b7c7c4534a0300de2 (diff)
Added a completely separate DTOBaseItem to remove the ApiBaseItemWrapper mess and shrink json output size.
Diffstat (limited to 'MediaBrowser.Model/Entities/IHasProviderIds.cs')
-rw-r--r--MediaBrowser.Model/Entities/IHasProviderIds.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/MediaBrowser.Model/Entities/IHasProviderIds.cs b/MediaBrowser.Model/Entities/IHasProviderIds.cs
new file mode 100644
index 000000000..3406d618b
--- /dev/null
+++ b/MediaBrowser.Model/Entities/IHasProviderIds.cs
@@ -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);
+ }
+ }
+}