Beispiel #1
0
 /// <summary>
 /// Zwraca element z sesji
 /// </summary>
 public T GetFromSession <T>(SessionItem itemName)
 {
     if (HttpContext.Current?.Session[itemName.ToString()] != null &&
         HttpContext.Current.Session[itemName.ToString()] is T)
     {
         return((T)HttpContext.Current.Session[itemName.ToString()]);
     }
     else
     {
         return(default(T));
     }
 }
Beispiel #2
0
 /// <summary>
 /// Dodaje element do Sesji [System.Web.HttpContext.Current.Session.Add(name, value)]
 /// </summary>
 public void AddToSession(SessionItem itemName, object value)
 {
     if (HttpContext.Current?.Session != null)
     {
         HttpContext.Current.Session.Add(itemName.ToString(), value);
     }
 }
Beispiel #3
0
        public void SessionItemFact()
        {
            var z = new SessionItem <string>()
            {
                Name = "woo", Value = string.Empty
            };

            Assert.Equal("woo|0", z.ToString());
        }