diff options
Diffstat (limited to 'MediaBrowser.Controller/Library/ItemDataCache.cs')
| -rw-r--r-- | MediaBrowser.Controller/Library/ItemDataCache.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Library/ItemDataCache.cs b/MediaBrowser.Controller/Library/ItemDataCache.cs new file mode 100644 index 000000000..35b3551a9 --- /dev/null +++ b/MediaBrowser.Controller/Library/ItemDataCache.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic;
+using MediaBrowser.Model.Entities;
+
+namespace MediaBrowser.Controller.Library
+{
+ public class ItemDataCache
+ {
+ private Dictionary<string, object> Data = new Dictionary<string, object>();
+
+ public void SetValue<T>(BaseItem item, string propertyName, T value)
+ {
+ Data[GetKey(item, propertyName)] = value;
+ }
+
+ public T GetValue<T>(BaseItem item, string propertyName)
+ {
+ string key = GetKey(item, propertyName);
+
+ if (Data.ContainsKey(key))
+ {
+ return (T)Data[key];
+ }
+
+ return default(T);
+ }
+
+ private string GetKey(BaseItem item, string propertyName)
+ {
+ return item.Id.ToString() + "-" + propertyName;
+ }
+ }
+}
|
