Files
mono/mcs/class/System.Web/System.Web.SessionState/SessionStateSectionHandler.cs
T
Jackson Harper 804bccf91f * HttpSessionState.cs: Make the SessionDictionary accessable
* ISessionHandler.cs: Add method to update the session state
	data in the handler. Pass the session config to handlers when
	initializing.
	* SessionConfig.cs: Add StateNetworkTimeout
	* SessionInProcHandler.cs: Updates because interface has
	changed, all functionality is the same.
	* SessionStateModule.cs: Get new config items, allow SQLServer
	session manager type. Update session handlers when the session
	state has been released.
	* SessionStateSectionHandler.cs: Add StateNetworkTimeout
	* SessionSQLServerHandler.cs: New class allows sessions to be
	stored in a database.

svn path=/trunk/mcs/; revision=19596
2003-11-03 21:08:59 +00:00

80 lines
2.2 KiB
C#

//
// System.Web.SessionState.SessionStateSectionHandler
//
// Authors:
// Gonzalo Paniagua Javier ([email protected])
//
// (C) 2003 Ximian, Inc (http://www.ximian.com)
//
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Xml;
namespace System.Web.SessionState
{
class SessionStateSectionHandler : IConfigurationSectionHandler
{
public object Create (object parent, object context, XmlNode section)
{
//TODO: context?
SessionConfig config = new SessionConfig (parent);
if (section.HasChildNodes)
ThrowException ("No children nodes allowed", section);
string attvalue = AttValue ("mode", section, false);
if (!config.SetMode (attvalue))
ThrowException ("Invalid mode value", section);
if (section.Attributes == null)
return config;
attvalue = AttValue ("cookieless", section);
if (attvalue != null)
if (!config.SetCookieLess (attvalue))
ThrowException ("Invalid cookieless value", section);
attvalue = AttValue ("timeout", section);
if (attvalue != null)
if (!config.SetTimeout (attvalue))
ThrowException ("Invalid timeout value", section);
attvalue = AttValue ("stateConnectionString", section);
if (attvalue != null)
config.SetStateConnectionString (attvalue);
attvalue = AttValue ("sqlConnectionString", section);
if (attvalue != null)
config.SetSqlConnectionString (attvalue);
attvalue = AttValue ("stateNetworkTimeout", section);
if (attvalue != null)
config.SetStateNetworkTimeout (attvalue);
if (section.Attributes != null && section.Attributes.Count > 0)
HandlersUtil.ThrowException ("Unknown attribute.", section);
return config;
}
// A few methods to save some typing
static string AttValue (string name, XmlNode node, bool optional)
{
return HandlersUtil.ExtractAttributeValue (name, node, optional);
}
static string AttValue (string name, XmlNode node)
{
return HandlersUtil.ExtractAttributeValue (name, node, true);
}
static void ThrowException (string message, XmlNode node)
{
HandlersUtil.ThrowException (message, node);
}
//
}
}