Beispiel #1
0
        public virtual IDictionary <string, object> LoadTempData(ControllerContext controllerContext)
        {
            string TempDataCacheStateKey = GetStateKey(controllerContext);

            Dictionary <string, object> dictionary = MemCaheHelper.Get(TempDataCacheStateKey) as Dictionary <string, object>;

            if (dictionary != null)
            {
                MemCaheHelper.Set(TempDataCacheStateKey, dictionary, DateTime.MinValue);
                return(dictionary);
            }
            return(new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase));
        }
Beispiel #2
0
        public virtual void SaveTempData(ControllerContext controllerContext, IDictionary <string, object> values)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            string TempDataCacheStateKey = GetStateKey(controllerContext);

            bool flag = values != null && values.Count > 0;

            if (flag)
            {
                MemCaheHelper.Set(TempDataCacheStateKey, values, DateTime.Now.AddMinutes(ExpiryTime));
                return;
            }

            if (MemCaheHelper.Get(TempDataCacheStateKey) != null)
            {
                MemCaheHelper.Set(TempDataCacheStateKey, values, DateTime.MinValue);
            }
        }