Skip to content

Instantly share code, notes, and snippets.

@eldewall
Created September 29, 2011 09:36
Show Gist options
  • Select an option

  • Save eldewall/1250401 to your computer and use it in GitHub Desktop.

Select an option

Save eldewall/1250401 to your computer and use it in GitHub Desktop.
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