/// <summary> /// Creates a new instance of the <see cref="AdaptiveSessionStorageProvider" /> class with the specified settings. /// </summary> /// <param name="settings">The <see cref="SessionStorageProviderElement" /> object that holds the configuration settings.</param> public AdaptiveSessionStorageProvider(SessionStorageProviderElement settings) : base(settings) { // TODO: error handle? SessionStateSection section = (SessionStateSection)ConfigurationManager.GetSection("system.web/sessionState"); if (section.Mode == SessionStateMode.Off || section.Mode == SessionStateMode.InProc) _provider = new InProcSessionStorageProvider(settings); else _provider = new SessionStateSessionStorageProvider(settings); }
/// <summary> /// Creates a new instance of the <see cref="AdaptiveSessionStorageProvider" /> class with the specified settings. /// </summary> /// <param name="settings">The <see cref="SessionStorageProviderElement" /> object that holds the configuration settings.</param> public AdaptiveSessionStorageProvider(SessionStorageProviderElement settings) : base(settings) { // TODO: error handle? SessionStateSection section = (SessionStateSection)ConfigurationManager.GetSection("system.web/sessionState"); if (section.Mode == SessionStateMode.Off || section.Mode == SessionStateMode.InProc) { _provider = new InProcSessionStorageProvider(settings); } else { _provider = new SessionStateSessionStorageProvider(settings); } }
/// <summary> /// Constructs and returns the <see cref="ISessionStorageProvider" /> defined by the current configuration. /// </summary> /// <returns>The <see cref="ISessionStorageProvider" /> defined by the current configuration.</returns> public ISessionStorageProvider Create() { if (string.IsNullOrEmpty(Type) || string.Equals(Type, "adaptive", StringComparison.InvariantCultureIgnoreCase)) { return(new AdaptiveSessionStorageProvider(this)); } else if (string.Equals(Type, "inproc", StringComparison.InvariantCultureIgnoreCase)) { return(new InProcSessionStorageProvider(this)); } else if (string.Equals(Type, "sessionstate", StringComparison.InvariantCultureIgnoreCase)) { return(new SessionStateSessionStorageProvider(this)); } else if (string.Equals(Type, "sqlclient", StringComparison.InvariantCultureIgnoreCase)) { return(new SqlClientSessionStorageProvider(this)); } else { ISessionStorageProvider provider = null; Exception innerEx = null; try { provider = (ISessionStorageProvider)TypeFactory.CreateInstance(Type, new object[] { this }); } catch (Exception ex) { innerEx = ex; } if (provider == null) { throw new Exception("Couldn't create SessionStorageProvider for type '" + Type + "'.", innerEx); } return(provider); } }
public SessionProvider(ISessionStorageProvider sessionStorageProvider) { _sessionStorageProvider = sessionStorageProvider; }