浏览代码

2005-11-28 Chris Toshok <[email protected]>

	* SessionStateModule.cs: CONFIGURATION_2_0 work.

	* SessionSQLServerHandler.cs: CONFIGURATION_2_0 work.

	* SessionInProcHandler.cs: CONFIGURATION_2_0 work.

	* SessionStateServerHandler.cs: CONFIGURATION_2_0 work.
	
	* ISessionHandler.cs (Init): @config is a SessionStateSection if
	CONFIGURATION_2_0.


svn path=/trunk/mcs/; revision=53603
Chris Toshok 20 年之前
父节点
当前提交
968ea3d729

+ 13 - 0
mcs/class/System.Web/System.Web.SessionState/ChangeLog

@@ -1,3 +1,16 @@
+2005-11-28  Chris Toshok  <[email protected]>
+
+	* SessionStateModule.cs: CONFIGURATION_2_0 work.
+
+	* SessionSQLServerHandler.cs: CONFIGURATION_2_0 work.
+
+	* SessionInProcHandler.cs: CONFIGURATION_2_0 work.
+
+	* SessionStateServerHandler.cs: CONFIGURATION_2_0 work.
+	
+	* ISessionHandler.cs (Init): @config is a SessionStateSection if
+	CONFIGURATION_2_0.
+
 2005-09-22 Gonzalo Paniagua Javier <[email protected]>
 
 	* SessionStateModule.cs: use the new funciton in HttpRequest.

+ 10 - 1
mcs/class/System.Web/System.Web.SessionState/ISessionHandler.cs

@@ -29,12 +29,21 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+using System.Web.Configuration;
+
 namespace System.Web.SessionState
 {
 	internal interface ISessionHandler
 	{
 		void Dispose ();
-		void Init (SessionStateModule module, HttpApplication context, SessionConfig config);
+		void Init (SessionStateModule module, HttpApplication context,
+#if CONFIGURATION_2_0
+			   SessionStateSection config
+#else
+			   SessionConfig config
+#endif
+			   );
 		HttpSessionState UpdateContext (HttpContext context, SessionStateModule module, bool required,
 						bool read_only, ref bool isNew);
 

+ 20 - 1
mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.cs

@@ -34,17 +34,28 @@ using System;
 using System.IO;
 using System.Collections;
 using System.Web.Caching;
+using System.Web.Configuration;
 
 namespace System.Web.SessionState
 {
 	class SessionInProcHandler : ISessionHandler
 	{
+#if CONFIGURATION_2_0
+		SessionStateSection config;
+#else
 		SessionConfig config;
+#endif
 		CacheItemRemovedCallback removedCB;
 		
 		public void Dispose () { }
 
-		public void Init (SessionStateModule module, HttpApplication context, SessionConfig config)
+		public void Init (SessionStateModule module, HttpApplication context,
+#if CONFIGURATION_2_0
+				  SessionStateSection config
+#else
+				  SessionConfig config
+#endif
+				  )
 		{
 			removedCB = new CacheItemRemovedCallback (module.OnSessionRemoved);
 			this.config = config;
@@ -80,13 +91,21 @@ namespace System.Web.SessionState
 			state = new HttpSessionState (sessionID, // unique identifier
 						new SessionDictionary(), // dictionary
 						HttpApplicationFactory.ApplicationState.SessionObjects,
+#if CONFIGURATION_2_0
+						(int)config.Timeout.TotalMinutes, // XXX is this right?  we lose some precision here, but since the timeout is in minutes *anyway*...
+#else
 						config.Timeout, //lifetime before death.
+#endif
 						true, //new session
 						false, // is cookieless
 						SessionStateMode.InProc,
 						read_only); //readonly
 
+#if CONFIGURATION_2_0
+			TimeSpan timeout = TimeSpan.FromMinutes ((int)config.Timeout.TotalMinutes);
+#else
 			TimeSpan timeout = new TimeSpan (0, config.Timeout, 0);
+#endif
 			cache.InsertPrivate ("@@@InProc@" + sessionID, state, null, Cache.NoAbsoluteExpiration,
 					timeout, CacheItemPriority.AboveNormal, removedCB);
 

+ 25 - 3
mcs/class/System.Web/System.Web.SessionState/SessionSQLServerHandler.cs

@@ -34,6 +34,7 @@ using System.Data;
 using System.Reflection;
 using System.Configuration;
 using System.Collections.Specialized;
+using System.Web.Configuration;
 
 namespace System.Web.SessionState {
 
@@ -41,7 +42,11 @@ namespace System.Web.SessionState {
 	{
 		private static Type cncType = null;
 		private IDbConnection cnc = null;
+#if CONFIGURATION_2_0
+		private SessionStateSection config;
+#else
 		private SessionConfig config;
+#endif
 
 		public void Dispose ()
 		{
@@ -51,7 +56,13 @@ namespace System.Web.SessionState {
 			}
 		}
 
-		public void Init (SessionStateModule module, HttpApplication context, SessionConfig config)
+		public void Init (SessionStateModule module, HttpApplication context,
+#if CONFIGURATION_2_0
+				  SessionStateSection config
+#else
+				  SessionConfig config
+#endif
+				  )
 		{
 			string connectionTypeName;
 			string providerAssemblyName;
@@ -111,10 +122,21 @@ namespace System.Web.SessionState {
 
 			id = SessionId.Create (module.Rng);
 			session = new HttpSessionState (id, new SessionDictionary (),
-					HttpApplicationFactory.ApplicationState.SessionObjects, config.Timeout,
+					HttpApplicationFactory.ApplicationState.SessionObjects,
+#if CONFIGURATION_2_0
+					(int)config.Timeout.TotalMinutes,
+#else
+					config.Timeout,
+#endif
 					true, config.CookieLess, SessionStateMode.SQLServer, read_only);
 
-			InsertSession (session, config.Timeout);
+			InsertSession (session,
+#if CONFIGURATION_2_0
+				       (int)config.Timeout.TotalMinutes
+#else
+				       config.Timeout
+#endif
+				       );
 			isNew = true;
 			return session;
 		}

+ 25 - 1
mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs

@@ -29,6 +29,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+
+using System.Web.Configuration;
 using System.Web.Caching;
 using System.Web.Util;
 using System.Security.Cryptography;
@@ -61,8 +63,12 @@ namespace System.Web.SessionState
 				AppDomain.CurrentDomain.SetData("SessionStateModule.handlerType", value);
 			}
 		}
+#else
+#if CONFIGURATION_2_0
+		static SessionStateSection config;
 #else
 		static SessionConfig config;
+#endif
 		static Type handlerType;
 #endif		
 		ISessionHandler handler;
@@ -85,15 +91,23 @@ namespace System.Web.SessionState
 			handler.Dispose();
 		}
 
+#if CONFIGURATION_2_0
+		SessionStateSection GetConfig ()
+#else
 		SessionConfig GetConfig ()
+#endif
 		{
 			lock (locker) {
 				if (config != null)
 					return config;
 
+#if CONFIGURATION_2_0
+				config = (SessionStateSection) WebConfigurationManager.GetSection ("system.web/sessionState");
+#else
 				config = (SessionConfig) HttpContext.GetAppConfig ("system.web/sessionState");
 				if (config ==  null)
 					config = new SessionConfig (null);
+#endif
 
 #if TARGET_J2EE
 				if (config.Mode == SessionStateMode.SQLServer || config.Mode == SessionStateMode.StateServer)
@@ -116,7 +130,11 @@ namespace System.Web.SessionState
 		public void Init (HttpApplication app)
 		{
 			sessionForStaticFiles = (Environment.GetEnvironmentVariable ("MONO_XSP_STATIC_SESSION") != null);
+#if CONFIGURATION_2_0
+			SessionStateSection cfg = GetConfig ();
+#else
 			SessionConfig cfg = GetConfig ();
+#endif
 			if (handlerType == null)
 				return;
 
@@ -221,8 +239,14 @@ namespace System.Web.SessionState
 
 		internal void OnSessionRemoved (string key, object value, CacheItemRemovedReason reason)
 		{
+#if CONFIGURATION_2_0
+			SessionStateSection cfg = GetConfig ();
+#else
+			SessionConfig cfg = GetConfig ();
+#endif
+
 			// Only invoked for InProc (see msdn2 docs on SessionStateModule.End)
-			if (GetConfig ().Mode == SessionStateMode.InProc)
+			if (cfg.Mode == SessionStateMode.InProc)
 				HttpApplicationFactory.InvokeSessionEnd (value);
 		}
 		

+ 32 - 4
mcs/class/System.Web/System.Web.SessionState/SessionStateServerHandler.cs

@@ -33,6 +33,7 @@ using System;
 using System.IO;
 using System.Reflection;
 using System.Configuration;
+using System.Web.Configuration;
 using System.Runtime.Remoting;
 
 namespace System.Web.SessionState {
@@ -42,13 +43,23 @@ namespace System.Web.SessionState {
 		const string CookieName = "ASPSESSION";
 
 		private RemoteStateServer state_server;
+#if CONFIGURATION_2_0
+		private SessionStateSection config;
+#else
 		private SessionConfig config;
+#endif
 		
 		public void Dispose ()
 		{
 		}
 
-		public void Init (SessionStateModule module, HttpApplication context, SessionConfig config)
+		public void Init (SessionStateModule module, HttpApplication context,
+#if CONFIGURATION_2_0
+				  SessionStateSection config
+#else
+				  SessionConfig config
+#endif
+				  )
 		{
 			this.config = config;
 			RemotingConfiguration.Configure (null);
@@ -93,7 +104,12 @@ namespace System.Web.SessionState {
 					sobjs = HttpStaticObjectsCollection.FromByteArray (item.StaticObjectsData);
 					session = new HttpSessionState (id, dict,
 							HttpApplicationFactory.ApplicationState.SessionObjects,
-							config.Timeout, false, config.CookieLess,
+#if CONFIGURATION_2_0
+							(int)config.Timeout.TotalMinutes, // XXX is this right?  we lose some precision here, but since the timeout is in minutes *anyway*...
+#else
+							config.Timeout,
+#endif
+							false, config.CookieLess,
 							SessionStateMode.StateServer, read_only);
 
 					return session;
@@ -103,11 +119,23 @@ namespace System.Web.SessionState {
 			id = SessionId.Create (module.Rng);
 			dict = new SessionDictionary ();
 			sobjs = HttpApplicationFactory.ApplicationState.SessionObjects;
-			item = new StateServerItem (dict.ToByteArray (), sobjs.ToByteArray (), config.Timeout);
+			item = new StateServerItem (dict.ToByteArray (), sobjs.ToByteArray (),
+#if CONFIGURATION_2_0
+						    (int)config.Timeout.TotalMinutes
+#else
+						    config.Timeout
+#endif
+						    );
 			
 			state_server.Insert (id, item);
 
-			session = new HttpSessionState (id, dict, sobjs, config.Timeout, true,
+			session = new HttpSessionState (id, dict, sobjs,
+#if CONFIGURATION_2_0
+							(int)config.Timeout.TotalMinutes,
+#else
+							config.Timeout,
+#endif
+							true,
 							config.CookieLess, SessionStateMode.StateServer,
 							read_only);