Created
September 29, 2011 09:36
-
-
Save eldewall/1250401 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ObjectStore { | |
| private static Dictionary<int, SalesObject> _objects = new Dictionary<int, SalesObject>(); | |
| public static T GetObject<T>(int contactId) where T : SalesObject { | |
| SalesObject tmpAccessory = null; | |
| _objects.TryGetValue(contactId, out tmpAccessory); | |
| return (T)tmpAccessory; | |
| } | |
| public static void Store(int contactId, SalesObject accessory) { | |
| if (GetObject<SalesObject>(contactId) != null) { | |
| _objects.Remove(contactId); | |
| } | |
| _objects.Add(contactId, accessory); | |
| } | |
| public static void Clear(int contactId) { | |
| _objects.Remove(contactId); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment