using System; using System.Collections.Generic; using System.Threading; namespace ${glPackageBaseCommon} { public class ${glInternalMapContextName} { private static LocalDataStoreSlot _internalMapSlot = Thread.AllocateDataSlot(); protected static void Initialize() { if (Thread.GetData(_internalMapSlot) != null) { return; } Thread.SetData(_internalMapSlot, new Dictionary()); } public static Object GetObject(String key) { Initialize(); IDictionary map = (IDictionary)Thread.GetData(_internalMapSlot); if (!map.ContainsKey(key)) { return null; } return map[key]; } public static void SetObject(String key, Object value) { Initialize(); IDictionary map = (IDictionary)Thread.GetData(_internalMapSlot); map.Add(key, value); } public static void ClearInternalMapOnThread() { Thread.SetData(_internalMapSlot, null); } public static bool IsExistInternalMapOnThread() { return (Thread.GetData(_internalMapSlot) != null); } } }