Пример #1
0
 public static bool SetDataWithKey(string sessionName, object key, object data, int expirationMinute = 0)
 {
     if (expirationMinute > 0)
     {
         ExpirationSolution.Add(sessionName, expirationMinute);
     }
     return(OCBSession.TrySet(sessionName, new DataWidthKey(key, data)));
 }
Пример #2
0
 public static bool SetData(string sessionName, object ob, int expirationMinute = 0)
 {
     if (expirationMinute > 0)
     {
         ExpirationSolution.Add(sessionName, expirationMinute);
     }
     return(OCBSession.TrySet(sessionName, ob));
 }
Пример #3
0
        public static List <T> GetListData <T>(string entryName, bool removeEntry = false)
        {
            object ob;

            if (OCBSession.TryGet(entryName, out ob, removeEntry))
            {
                return((List <T>)ob);
            }
            return(null);
        }
Пример #4
0
        public static T GetData <T>(string entryName, bool removeEntry = false)
        {
            object ob;

            if (OCBSession.TryGet(entryName, out ob, removeEntry))
            {
                DataWidthKey ret = ob as DataWidthKey;
                if (ret != null)
                {
                    return((T)ret.Data);
                }
                else
                {
                    return((T)ob);
                }
            }
            return(default(T));
        }
Пример #5
0
        public static T GetDataWithKey <T>(string sessionName, object key, bool removeIfKeyNotMatch = true, bool removeSession = false)
        {
            object ob = null;

            if (OCBSession.TryGet(sessionName, out ob, removeSession))
            {
                DataWidthKey dw = ob as DataWidthKey;
                if (dw != null)
                {
                    if (dw.Key.Equals(key))
                    {
                        return((T)dw.Data);
                    }
                    else if (!removeSession && removeIfKeyNotMatch)
                    {
                        OCBSession.Remove(sessionName);
                    }
                }
            }
            return(default(T));
        }
Пример #6
0
 public static bool RemoveAllData()
 {
     return(OCBSession.RemoveAll());
 }
Пример #7
0
 public static bool RemoveData(string sessionName)
 {
     return(OCBSession.Remove(sessionName));
 }