From b50f78e5da6f3fdfc59e577ca61b88771da7d211 Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Thu, 12 Jul 2012 02:55:27 -0400 Subject: Initial check-in --- MediaBrowser.Controller/Library/ItemDataCache.cs | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 MediaBrowser.Controller/Library/ItemDataCache.cs (limited to 'MediaBrowser.Controller/Library/ItemDataCache.cs') 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 Data = new Dictionary(); + + public void SetValue(BaseItem item, string propertyName, T value) + { + Data[GetKey(item, propertyName)] = value; + } + + public T GetValue(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; + } + } +} -- cgit v1.2.3