Beispiel #1
0
 /// <summary>
 /// A relaxed utility function that doesn't impose mandatory requirements for Session values to exist in the Session.
 /// Returns a value from Session if it exists. Returns null if value isn't present.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="var"></param>
 /// <returns></returns>
 private static Nullable <T> GetNullableSessionValue <T>(SessionVars var) where T : struct
 {
     if (HttpContext.Current.Session[var.Description()] != null)
     {
         return((T)HttpContext.Current.Session[var.Description()]);
     }
     else
     {
         return(null);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Private helper Generic function to facilitate retrieval of value from Session
 /// </summary>
 private static T GetNonNullSessionValue <T>(SessionVars variableName)
 {
     if (DoesSessionVariableExist(variableName))
     {
         return((T)HttpContext.Current.Session[variableName.Description()]);
     }
     else
     {
         string error = "Unable to retrieve session value for : " + variableName.Description();
         throw new ShiptalkCommon.ShiptalkException(error, true, new System.Security.SecurityException(error), "Sorry. We lost some session information. Please login again.");
     }
 }
Beispiel #3
0
 /// <summary>
 /// Verifies Session for the existence of a value for a Session variable.
 /// </summary>
 /// <param name="var"></param>
 /// <returns></returns>
 public static bool DoesSessionVariableExist(SessionVars var)
 {
     if (HttpContext.Current.Session != null)
     {
         return(!(HttpContext.Current.Session[var.Description()] == null));
     }
     else
     {
         return(false);
     }
 }
Beispiel #4
0
 /// <summary>
 /// Private helper Generic function to facilitate setting value to Session variable.
 /// </summary>
 private static void SetSessionValue <T>(SessionVars variableName, T value)
 {
     HttpContext.Current.Session[variableName.Description()] = value;
 }