/// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        internal static BaseSessionObject GetSessionObject(User user)
        {
            BaseSessionObject sessionObject = CreateSessionObject();

            sessionObject.Init(user);
            var context = HttpContextUtilities.GetHttpContext();

            SaveSessionObjectToHttpContext(sessionObject, context);
            return(sessionObject);
        }
        /// <summary>
        /// Create a session object for specific user account
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        internal static BaseSessionObject GetSessionObject(string username, string password)
        {
            BaseSessionObject sessionObject = CreateSessionObject();

            sessionObject.Init(username, password);
            var context = HttpContextUtilities.GetHttpContext();

            SaveSessionObjectToHttpContext(sessionObject, context);
            return(sessionObject);
        }
        /// <summary>
        /// Save session object to http context so that other http modules and handlers can use it without initializing again
        /// </summary>
        /// <param name="sessionObject"></param>
        /// <param name="context"></param>
        private static void SaveSessionObjectToHttpContext(BaseSessionObject sessionObject, HttpContextBase context)
        {
            if (context == null)
            {
                return;
            }

            if (context.Items.Contains(SESSION_NAME))
            {
                context.Items[SESSION_NAME] = sessionObject;
            }
            else
            {
                context.Items.Add(SESSION_NAME, sessionObject);
            }
        }
        private static BaseSessionObject CreateSessionObjectFromConfiguration()
        {
            BaseSessionObject sessionObject = null;
            Type sessionType = Type.GetType("Misuka.Domain.Providers.SessionObject");

            try
            {
                if (sessionType != null)
                {
                    sessionObject = (BaseSessionObject)Activator.CreateInstance(sessionType);
                }
            }

            catch (Exception ex)
            {
                throw new ConfigurationErrorsException("Could not create an instance of DashboardSession", ex);
            }
            return(sessionObject);
        }
 public static void ResetSessionObject()
 {
     _sessionObject = null;
 }
 internal static void SetSessionObject(BaseSessionObject sessionObject)
 {
     _sessionObject = sessionObject;
 }
示例#7
0
 internal UserSession(BaseSessionObject sessionObject)
 {
     _sessionObject = sessionObject;
 }
示例#8
0
 internal UserSession(User loggingUser)
 {
     _sessionObject = SessionObjectFactory.GetSessionObject(loggingUser);
 }
示例#9
0
 internal UserSession(User loggingUser)
 {
   _sessionObject = SessionObjectFactory.GetSessionObject(loggingUser);
 }
示例#10
0
 public UserSession()
 {
     _sessionObject = SessionObjectFactory.GetSessionObject();
 }
示例#11
0
 internal UserSession(BaseSessionObject sessionObject)
 {
   _sessionObject = sessionObject;
 }
示例#12
0
 public UserSession()
 {
   _sessionObject = SessionObjectFactory.GetSessionObject();
 }
示例#13
0
 public static void ResetSessionObject()
 {
   _sessionObject = null;
 }
示例#14
0
 internal static void SetSessionObject(BaseSessionObject sessionObject)
 {
   _sessionObject = sessionObject;
 }
示例#15
0
    /// <summary>
    /// Save session object to http context so that other http modules and handlers can use it without initializing again
    /// </summary>
    /// <param name="sessionObject"></param>
    /// <param name="context"></param>
    private static void SaveSessionObjectToHttpContext(BaseSessionObject sessionObject, HttpContextBase context)
    {
      if (context == null) return;

      if (context.Items.Contains(SESSION_NAME)) context.Items[SESSION_NAME] = sessionObject;
      else context.Items.Add(SESSION_NAME, sessionObject);
    }