Пример #1
0
 public static T GetSessionValue <T> (this HttpSessionState session,
                                      string key, UponCreate uponCreate) where T : struct
 {
     if (null == session[key])
     {
         var item = uponCreate();
         session[key] = item;
         return((T)item);
     }
     return((T)session[key]);
 }
Пример #2
0
 public static T GetSessionClass <T> (this HttpSessionState session,
                                      string key, UponCreate uponCreate) where T : class
 {
     if (null == session[key])
     {
         var item = uponCreate() as T;
         session[key] = item;
         return(item);
     }
     return(session[key] as T);
 }