Implementation of the 2.0 session state model
authorMarek Habersack <grendel@twistedcode.net>
Wed, 20 Dec 2006 18:34:00 +0000 (18:34 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 20 Dec 2006 18:34:00 +0000 (18:34 -0000)
svn path=/trunk/mcs/; revision=69828

37 files changed:
1  2  3 
mcs/class/System.Web/ChangeLog
mcs/class/System.Web/System.Web.SessionState/HttpSessionState.cs
mcs/class/System.Web/System.Web.SessionState/IHttpSessionState.cs
mcs/class/System.Web/System.Web.SessionState/ISessionIDManager.cs
mcs/class/System.Web/System.Web.SessionState/ISessionStateItemCollection.cs
mcs/class/System.Web/System.Web.SessionState/RemoteStateServer.cs
mcs/class/System.Web/System.Web.SessionState/SessionId.cs
mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.cs
mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.jvm.cs
mcs/class/System.Web/System.Web.SessionState/SessionSQLServerHandler.cs
mcs/class/System.Web/System.Web.SessionState/SessionStateActions.cs
mcs/class/System.Web/System.Web.SessionState/SessionStateItemExpireCallback.cs
mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs
mcs/class/System.Web/System.Web.SessionState/SessionStateServerHandler.cs
mcs/class/System.Web/System.Web.SessionState/SessionStateStoreData.cs
mcs/class/System.Web/System.Web.SessionState/StateServerItem.cs
mcs/class/System.Web/System.Web.SessionState_2.0/HttpSessionState.cs
mcs/class/System.Web/System.Web.SessionState_2.0/HttpSessionStateContainer.cs
mcs/class/System.Web/System.Web.SessionState_2.0/IHttpSessionState.cs
mcs/class/System.Web/System.Web.SessionState_2.0/ISessionIDManager.cs
mcs/class/System.Web/System.Web.SessionState_2.0/ISessionStateItemCollection.cs
mcs/class/System.Web/System.Web.SessionState_2.0/RemoteStateServer.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionIDManager.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionInProcHandler.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionSQLServerHandler.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateActions.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateItemCollection.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateItemExpireCallback.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateModule.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateServerHandler.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateStoreData.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateStoreProviderBase.cs
mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateUtility.cs
mcs/class/System.Web/System.Web.SessionState_2.0/StateServerItem.cs
mcs/class/System.Web/System.Web.UI/TemplateParser.cs
mcs/class/System.Web/System.Web.dll.sources
mcs/class/System.Web/System.Web/HttpApplicationFactory.cs

index 1555c9f8e808df1f765831abc7bf8b7fcf3b2c46,e63a8209c21e53885c3166427c2ce1d89d9a2432,2620aa168b791901161b8bf4fefec5ceff11f815..51de35282704f959123e07831ed2447c85b5b548
@@@@ -1,12 -1,3 -1,7 +1,70 @@@@
+++2006-12-20  Marek Habersack  <grendello@gmail.com>
+++
+++     * System.Web.dll.sources: adjustments for the 2.0 SessionState
+++     changes.
+++
+++     * System.Web.SessionState_2.0/SessionStateServerHandler.cs:
+++     implemented for the 2.0 model.
+++
+++     * System.Web.SessionState_2.0/SessionStateUtility.cs:
+++     implemented.
+++
+++     * System.Web.SessionState_2.0/SessionStateStoreProviderBase.cs:
+++     implemented.
+++
+++     * System.Web.SessionState_2.0/SessionInProcHandler.cs:
+++     reimplemented for the 2.0 model.
+++
+++     * System.Web.SessionState_2.0/SessionIDManager.cs: implemented.
+++
+++     * System.Web.SessionState_2.0/SessionStateModule.cs: copied the
+++     file to new location and implemented the 2.0 model.
+++
+++     * System.Web.SessionState_2.0/SessionSQLServerHandler.cs:
+++     created. Implementation not done yet.
+++
+++     * System.Web.SessionState_2.0/HttpSessionStateContainer.cs: copied
+++     the file to new location and implemented the 2.0 model.
+++
+++     * System.Web.SessionState_2.0/StateServerItem.cs: implementation
+++     for the 2.0 model.
+++
+++     * System.Web.SessionState_2.0/HttpSessionState.cs: reimplemented
+++     for the 2.0 model.
+++
+++     * System.Web.SessionState_2.0/RemoteStateServer.cs: copied the
+++     file to new location and added new code for the 2.0 model.
+++
+++     * System.Web.SessionState_2.0/SessionStateItemCollection.cs:
+++     implemented.
+++
+++     * System.Web.SessionState_2.0/SessionStateActions.cs: moved the
+++     file to new location and added the None member.
+++
+++     * System.Web.SessionState_2.0/ISessionIDManager.cs: moved the file
+++     to new location.
+++
+++     * System.Web.SessionState_2.0/SessionStateItemExpireCallback.cs:
+++     moved the file to new location.
+++
+++     * System.Web.SessionState_2.0/IHttpSessionState.cs: moved the file
+++     to new location.
+++
+++     * System.Web.SessionState_2.0/SessionStateStoreData.cs: moved the
+++     file to new location and modified for the 2.0 model.
+++
+++     * System.Web.SessionState_2.0/ISessionStateItemCollection.cs:
+++     moved the file to new location.
+++
 ++2006-12-09  Marek Habersack  <grendello@gmail.com>
 ++
 ++     * System.Web.dll.sources: Add the HiddenFieldPageStatePersister.cs
 ++     file to compilation
 ++
 + 2006-12-05  Yoni Klain   <yonik@mainsoft.com>
 + 
 +      * MakeFile added new resources TextBoxTestlPage.aspx for TextBoxTest.cs
 + 
   2006-11-29  Yoni Klain   <yonik@mainsoft.com>
   
        * MakeFile added new resources ListControlPage.aspx for ListControlTest.cs
index 2867059771811c03417817df0366752c441acd66,2867059771811c03417817df0366752c441acd66,2867059771811c03417817df0366752c441acd66..361abf21e65c75c3b2bb7c70593e6280094698c8
   // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
---
+++#if !NET_2_0
   using System.Collections;
   using System.Collections.Specialized;
   using System.Globalization;
@@@@ -217,4 -217,4 -217,4 +217,4 @@@@ public sealed class HttpSessionState : 
        }
   }
   }
---
+++#endif
diff --cc mcs/class/System.Web/System.Web.SessionState/IHttpSessionState.cs
index 978208249d0a2f2b7d9e134453ed6b8e93a343de,978208249d0a2f2b7d9e134453ed6b8e93a343de,978208249d0a2f2b7d9e134453ed6b8e93a343de..0000000000000000000000000000000000000000
deleted file mode 100644,100644,100644
+++ /dev/null
@@@@ -1,69 -1,69 -1,69 +1,0 @@@@
---//
---// System.Web.SessionState.IReadOnlySessionState
---//
---// Authors:
---//   Sanjay Gupta (gsanjay@novell.com)
---//
---// (C) 2004 Novell, Inc (http://www.novell.com)
---//
---
---//
---// Permission is hereby granted, free of charge, to any person obtaining
---// a copy of this software and associated documentation files (the
---// "Software"), to deal in the Software without restriction, including
---// without limitation the rights to use, copy, modify, merge, publish,
---// distribute, sublicense, and/or sell copies of the Software, and to
---// permit persons to whom the Software is furnished to do so, subject to
---// the following conditions:
---// 
---// The above copyright notice and this permission notice shall be
---// included in all copies or substantial portions of the Software.
---// 
---// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
---// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
---// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
---// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
---// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
---// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
---// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---//
---
---#if NET_2_0
---
---using System.Collections;
---using System.Collections.Specialized;
---
---namespace System.Web.SessionState {
---     public interface IHttpSessionState
---     {
---             ///methods
---             void Abandon ();
---             void Add (string itemName, object itemValue);
---             void Clear ();
---             void CopyTo (Array sessionValues, int index);
---             IEnumerator GetEnumerator ();
---             void Remove (string itemName);
---             void RemoveAll ();
---             void RemoveAt (int index);
---     
---             ///properties
---             int CodePage { get; set; }
---             HttpCookieMode CookieMode { get; }
---             int Count { get; }              
---             bool IsCookieless { get; }
---             bool IsNewSession { get; }
---             bool IsReadOnly { get; }
---             bool IsSynchronized { get; }
---             object this [int index] { get; set; }
---             object this [string name] { get; set;}
---             NameObjectCollectionBase.KeysCollection Keys { get; }
---             int LCID { get; set; }
---             SessionStateMode Mode { get; }
---             string SessionID { get; }
---             HttpStaticObjectsCollection StaticObjects { get; }
---             object SyncRoot { get; }
---             int Timeout { get; set; }                       
---     }
---}
---#endif
---
diff --cc mcs/class/System.Web/System.Web.SessionState/ISessionIDManager.cs
index d3742521a3e06dbf2a5395a6f47a458b94f63d88,d3742521a3e06dbf2a5395a6f47a458b94f63d88,d3742521a3e06dbf2a5395a6f47a458b94f63d88..0000000000000000000000000000000000000000
deleted file mode 100644,100644,100644
+++ /dev/null
@@@@ -1,50 -1,50 -1,50 +1,0 @@@@
---//
---// System.Web.SessionState.ISessionIDManager
---//
---// Authors:
---//   Sanjay Gupta (gsanjay@novell.com)
---//
---// (C) 2004 Novell, Inc (http://www.novell.com)
---//
---
---//
---// Permission is hereby granted, free of charge, to any person obtaining
---// a copy of this software and associated documentation files (the
---// "Software"), to deal in the Software without restriction, including
---// without limitation the rights to use, copy, modify, merge, publish,
---// distribute, sublicense, and/or sell copies of the Software, and to
---// permit persons to whom the Software is furnished to do so, subject to
---// the following conditions:
---// 
---// The above copyright notice and this permission notice shall be
---// included in all copies or substantial portions of the Software.
---// 
---// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
---// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
---// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
---// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
---// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
---// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
---// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---//
---
---#if NET_2_0
---
---using System;
---using System.Web;
---
---namespace System.Web.SessionState {
---     public interface ISessionIDManager
---     {
---             ///methods
---             string CreateSessionID (HttpContext context);
---             string GetSessionID (HttpContext context);
---             void Initialize ();
---             bool InitializeRequest (HttpContext context, bool suppressAutoDetectRedirect, out bool supportSessionIDReissue);
---             void RemoveSessionID (HttpContext context);
---             void SaveSessionID (HttpContext context, string sessionID, out bool isRedirected, out bool isCookieAdded);
---             bool Validate (string id);
---     }
---}
---#endif
---
diff --cc mcs/class/System.Web/System.Web.SessionState/ISessionStateItemCollection.cs
index c76294f36e8a3b050f14e92295606891e4277057,c76294f36e8a3b050f14e92295606891e4277057,c76294f36e8a3b050f14e92295606891e4277057..0000000000000000000000000000000000000000
deleted file mode 100644,100644,100644
+++ /dev/null
@@@@ -1,51 -1,51 -1,51 +1,0 @@@@
---//
---// System.Web.SessionState.ISessionStateItemCollection
---//
---// Authors:
---//   Sanjay Gupta (gsanjay@novell.com)
---//
---// Copyright (c) 2004-2005 Novell, Inc (http://www.novell.com)
---//
---// Permission is hereby granted, free of charge, to any person obtaining
---// a copy of this software and associated documentation files (the
---// "Software"), to deal in the Software without restriction, including
---// without limitation the rights to use, copy, modify, merge, publish,
---// distribute, sublicense, and/or sell copies of the Software, and to
---// permit persons to whom the Software is furnished to do so, subject to
---// the following conditions:
---// 
---// The above copyright notice and this permission notice shall be
---// included in all copies or substantial portions of the Software.
---// 
---// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
---// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
---// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
---// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
---// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
---// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
---// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---//
---
---#if NET_2_0
---
---using System.Collections;
---using System.Collections.Specialized;
---
---namespace System.Web.SessionState {
---
---     public interface ISessionStateItemCollection : ICollection, IEnumerable
---     {
---             ///methods
---             void Clear ();
---             void Remove (string itemName);
---             void RemoveAt (int index);
---     
---             ///properties
---             bool Dirty { get; set; }
---             object this [int index] { get; set; }
---             object this [string name] { get; set;}
---             NameObjectCollectionBase.KeysCollection Keys { get; }
---     }
---}
---#endif
---
index d38544fa8b65eec879482e2742f36f0b0722977e,d38544fa8b65eec879482e2742f36f0b0722977e,d38544fa8b65eec879482e2742f36f0b0722977e..cf5037a5cafeb1b5e79d065bfc7700e08d74c4a8
   // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
---
+++#if !NET_2_0
   using System;
   using System.Web.Caching;
   
@@@@ -86,4 -86,4 -86,4 +86,4 @@@@ namespace System.Web.SessionState 
                }
        }
   }
---
+++#endif
index 9c7167024614ca85af7d719467365faad0c7ebd6,9c7167024614ca85af7d719467365faad0c7ebd6,9c7167024614ca85af7d719467365faad0c7ebd6..2399b8a5a435893f434a8a0dfae36d74be498c3c
@@@@ -39,12 -39,12 -39,12 +39,10 @@@@ namespace System.Web.SessionState 
   
                internal const int IdLength = 24;
                private const int half_len = IdLength / 2;
+++             static RandomNumberGenerator rng = RandomNumberGenerator.Create ();
                
---             internal static string Create (RandomNumberGenerator rng)
+++             internal static string Create ()
                {
---                     if (rng == null)
---                             throw new ArgumentNullException ("rng");
---                     
                        byte[] key = new byte [half_len];
   
                        lock (rng) {
index de5db8c303d78705d517eac03f9a9867a4958675,de5db8c303d78705d517eac03f9a9867a4958675,de5db8c303d78705d517eac03f9a9867a4958675..861ee82c3a496049e8409c9c662d73cd885395c0
   // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
---
+++#if !NET_2_0
   using System;
   using System.IO;
   using System.Collections;
@@@@ -40,22 -40,22 -40,22 +40,13 @@@@ namespace System.Web.SessionStat
   {
        class SessionInProcHandler : ISessionHandler
        {
---#if NET_2_0
---             SessionStateSection config;
---#else
                SessionConfig config;
---#endif
                CacheItemRemovedCallback removedCB;
                
                public void Dispose () { }
   
                public void Init (SessionStateModule module, HttpApplication context,
---#if NET_2_0
---                               SessionStateSection config
---#else
---                               SessionConfig config
---#endif
---                               )
+++                               SessionConfig config)
                {
                        removedCB = new CacheItemRemovedCallback (module.OnSessionRemoved);
                        this.config = config;
                        }
   
                        // Create a new session.
---                     string sessionID = SessionId.Create (module.Rng);
+++                     string sessionID = SessionId.Create ();
                        state = new HttpSessionState (sessionID, // unique identifier
                                                new SessionDictionary(), // dictionary
                                                HttpApplicationFactory.ApplicationState.SessionObjects,
---#if NET_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 NET_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);
   
        }
   }
   
+++#endif
index f7921cdca6e43d3ecfd37fd679f465cc56877753,f7921cdca6e43d3ecfd37fd679f465cc56877753,f7921cdca6e43d3ecfd37fd679f465cc56877753..1fedb456edc88746749cd179dfc5e36804f024f6
   // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
---
+++#if !NET_2_0
   using System;
   using System.IO;
   using System.Collections;
@@@@ -104,3 -104,3 -104,3 +104,4 @@@@ namespace System.Web.SessionStat
        }
   }
   
+++#endif
index 0587b6de6bc2bd0b4c3030f3bfea3be57a17ebe3,8cb11ca731f30c952a8726c53589385404103407,0587b6de6bc2bd0b4c3030f3bfea3be57a17ebe3..d4a41403656bb2cdf0d3ca6ac66909c39b997306
   // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
---
+++#if !NET_2_0
   using System;
   using System.IO;
   using System.Data;
@@@@ -42,11 -42,11 -42,11 +42,7 @@@@ namespace System.Web.SessionState 
        {
                private static Type cncType = null;
                private IDbConnection cnc = null;
---#if NET_2_0
---             private SessionStateSection config;
---#else
                private SessionConfig config;
---#endif
                   
                const string defaultParamPrefix = ":";
                string paramPrefix;
                }
   
                public void Init (SessionStateModule module, HttpApplication context,
---#if NET_2_0
---                               SessionStateSection config
---#else
---                               SessionConfig config
---#endif
---                               )
+++                               SessionConfig config)
                {
                        string connectionTypeName;
                        string providerAssemblyName;
                                        return session;
                        }
   
---                     id = SessionId.Create (module.Rng);
+++                     id = SessionId.Create ();
                        session = new HttpSessionState (id, new SessionDictionary (),
                                        HttpApplicationFactory.ApplicationState.SessionObjects,
---#if NET_2_0
---                                     (int)config.Timeout.TotalMinutes,
---#else
                                        config.Timeout,
---#endif
                                        true, config.CookieLess, SessionStateMode.SQLServer, read_only);
   
---                     InsertSessionWithRetry (session,
---#if NET_2_0
---                                    (int)config.Timeout.TotalMinutes
---#else
---                                    config.Timeout
---#endif
---                                    );
+++                     InsertSessionWithRetry (session, config.Timeout);
                        isNew = true;
                        return session;
                }
                }
        }
   }
---
+++#endif
diff --cc mcs/class/System.Web/System.Web.SessionState/SessionStateActions.cs
index f3bfc7ec039b665fc5b6184dd445e9ffed8deaf9,f3bfc7ec039b665fc5b6184dd445e9ffed8deaf9,f3bfc7ec039b665fc5b6184dd445e9ffed8deaf9..0000000000000000000000000000000000000000
deleted file mode 100644,100644,100644
+++ /dev/null
@@@@ -1,36 -1,36 -1,36 +1,0 @@@@
---//
---// System.Web.SessionState.SessionStateActions.cs
---//
---// Authors:
---//   Sanjay Gupta (gsanjay@novell.com)
---//
---// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
---//
---// Permission is hereby granted, free of charge, to any person obtaining
---// a copy of this software and associated documentation files (the
---// "Software"), to deal in the Software without restriction, including
---// without limitation the rights to use, copy, modify, merge, publish,
---// distribute, sublicense, and/or sell copies of the Software, and to
---// permit persons to whom the Software is furnished to do so, subject to
---// the following conditions:
---// 
---// The above copyright notice and this permission notice shall be
---// included in all copies or substantial portions of the Software.
---// 
---// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
---// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
---// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
---// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
---// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
---// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
---// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---//
---
---#if NET_2_0
---namespace System.Web.SessionState {
---     public enum SessionStateActions {
---             InitializeItem  = 1
---     }
---}
---#endif
---
diff --cc mcs/class/System.Web/System.Web.SessionState/SessionStateItemExpireCallback.cs
index 3b2c04d1c02704ae393f12ee2c2bca8d0b418ebf,3b2c04d1c02704ae393f12ee2c2bca8d0b418ebf,3b2c04d1c02704ae393f12ee2c2bca8d0b418ebf..0000000000000000000000000000000000000000
deleted file mode 100644,100644,100644
+++ /dev/null
@@@@ -1,38 -1,38 -1,38 +1,0 @@@@
---//
---// System.Web.SessionState.SessionStateItemExpireCallback
---//
---// Authors:
---//   Sanjay Gupta (gsanjay@novell.com)
---//
---// (C) 2004 Novell, Inc (http://www.novell.com)
---//
---
---//
---// Permission is hereby granted, free of charge, to any person obtaining
---// a copy of this software and associated documentation files (the
---// "Software"), to deal in the Software without restriction, including
---// without limitation the rights to use, copy, modify, merge, publish,
---// distribute, sublicense, and/or sell copies of the Software, and to
---// permit persons to whom the Software is furnished to do so, subject to
---// the following conditions:
---// 
---// The above copyright notice and this permission notice shall be
---// included in all copies or substantial portions of the Software.
---// 
---// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
---// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
---// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
---// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
---// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
---// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
---// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---//
---
---#if NET_2_0
---namespace System.Web.SessionState
---{
---     public delegate void SessionStateItemExpireCallback (
---                             string id, SessionStateStoreData item);
---}
---
---#endif
index 166299662f95382bb4c773ac72b8f2884492a8ab,166299662f95382bb4c773ac72b8f2884492a8ab,166299662f95382bb4c773ac72b8f2884492a8ab..1deb4fb1adc707e1638df800ba57bab1481f4fb4
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
   
---
+++#if !NET_2_0
   using System.Web.Configuration;
   using System.Web.Caching;
   using System.Web.Util;
@@@@ -47,30 -47,30 -47,30 +47,7 @@@@ namespace System.Web.SessionStat
                static object locker = new object ();
                
   #if TARGET_J2EE              
---#if NET_2_0
---             static private SessionStateSection config {
---                     get
---                     {
---                             return (SessionStateSection) AppDomain.CurrentDomain.GetData ("SessionStateModule.config");
---                     }
---                     set
---                     {
---                             AppDomain.CurrentDomain.SetData ("SessionStateModule.config", value);
---                     }
---             }
---             static private Type handlerType
---             {
---                     get
---                     {
---                             return (Type) AppDomain.CurrentDomain.GetData ("SessionStateModule.handlerType");
---                     }
---                     set
---                     {
---                             AppDomain.CurrentDomain.SetData ("SessionStateModule.handlerType", value);
---                     }
---             }
---#else
---             static private SessionConfig config {
+++static private SessionConfig config {
                        get {
                                return (SessionConfig)AppDomain.CurrentDomain.GetData("SessionStateModule.config");
                        }
                                AppDomain.CurrentDomain.SetData("SessionStateModule.handlerType", value);
                        }
                }
---#endif
---#else
---#if NET_2_0
---             static SessionStateSection config;
   #else
                static SessionConfig config;
---#endif
                static Type handlerType;
   #endif               
                ISessionHandler handler;
                        handler.Dispose();
                }
   
---#if NET_2_0
---             SessionStateSection GetConfig ()
---#else
                SessionConfig GetConfig ()
---#endif
                {
                        lock (locker) {
                                if (config != null)
                                        return config;
   
---#if NET_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)
                public void Init (HttpApplication app)
                {
                        sessionForStaticFiles = (Environment.GetEnvironmentVariable ("MONO_XSP_STATIC_SESSION") != null);
---#if NET_2_0
---                     SessionStateSection cfg = GetConfig ();
---#else
                        SessionConfig cfg = GetConfig ();
---#endif
                        if (handlerType == null)
                                return;
   
   
                internal void OnSessionRemoved (string key, object value, CacheItemRemovedReason reason)
                {
---#if NET_2_0
---                     SessionStateSection cfg = GetConfig ();
---#else
                        SessionConfig cfg = GetConfig ();
---#endif
   
                        // Only invoked for InProc (see msdn2 docs on SessionStateModule.End)
                        if (cfg.Mode == SessionStateMode.InProc)
        }
   }
   
+++#endif
index 701d4c1b728682bb61d6e2e26b5c14c6cc1e2741,701d4c1b728682bb61d6e2e26b5c14c6cc1e2741,701d4c1b728682bb61d6e2e26b5c14c6cc1e2741..49f1cf987e1de026beb6cfff1e98dc1ecf8b519a
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
   
---
+++#if !NET_2_0
   using System;
   using System.IO;
   using System.Reflection;
@@@@ -116,7 -116,7 -116,7 +116,7 @@@@ namespace System.Web.SessionState 
                                }
                        }
                        
---                     id = SessionId.Create (module.Rng);
+++                     id = SessionId.Create ();
                        dict = new SessionDictionary ();
                        sobjs = HttpApplicationFactory.ApplicationState.SessionObjects;
                        item = new StateServerItem (dict.ToByteArray (), sobjs.ToByteArray (),
                }
        } 
   }
---
+++#endif
diff --cc mcs/class/System.Web/System.Web.SessionState/SessionStateStoreData.cs
index 359bd1049da60d9aac1daf48905adc73bb98bef0,359bd1049da60d9aac1daf48905adc73bb98bef0,359bd1049da60d9aac1daf48905adc73bb98bef0..0000000000000000000000000000000000000000
deleted file mode 100644,100644,100644
+++ /dev/null
@@@@ -1,66 -1,66 -1,66 +1,0 @@@@
---//
---// System.Web.SessionState.SessionStateStoreData.cs
---//
---// Authors:
---//   Sanjay Gupta (gsanjay@novell.com)
---//
---// (C) 2004 Novell, Inc (http://www.novell.com)
---//
---
---//
---// Permission is hereby granted, free of charge, to any person obtaining
---// a copy of this software and associated documentation files (the
---// "Software"), to deal in the Software without restriction, including
---// without limitation the rights to use, copy, modify, merge, publish,
---// distribute, sublicense, and/or sell copies of the Software, and to
---// permit persons to whom the Software is furnished to do so, subject to
---// the following conditions:
---// 
---// The above copyright notice and this permission notice shall be
---// included in all copies or substantial portions of the Software.
---// 
---// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
---// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
---// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
---// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
---// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
---// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
---// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---//
---
---#if NET_2_0
---
---using System.Web;
---
---namespace System.Web.SessionState {
---     public class SessionStateStoreData 
---     {
---             ISessionStateItemCollection sessionItems;
---             HttpStaticObjectsCollection staticObjects;
---             int timeout;
---
---             SessionStateStoreData (ISessionStateItemCollection items,
---                                     HttpStaticObjectsCollection objects,
---                                     int timeout)
---             {
---                     sessionItems = items;
---                     staticObjects = objects;
---                     this.timeout = timeout;
---             }
---
---             public virtual ISessionStateItemCollection Items { 
---                     get { return sessionItems ; }
---             }
---
---             public virtual HttpStaticObjectsCollection StaticObjects { 
---                     get { return staticObjects; }
---             }
---
---             public virtual int Timeout { 
---                     get { return timeout; }
---                     set { timeout = value; }
---             }
---     }               
---}
---
---#endif
index ec006dc0f93e08116a3bcf46da8c014110ca356d,ec006dc0f93e08116a3bcf46da8c014110ca356d,ec006dc0f93e08116a3bcf46da8c014110ca356d..ad43c2bf1d75765a6ec900e52fc2e924627258b3
   // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
---
+++#if !NET_2_0
   using System;
   
   namespace System.Web.SessionState {
                        this.dict_data = dict_data;
                        this.sobjs_data = sobjs_data;
                        this.timeout = timeout;
---                     this.last_access = DateTime.Now;
+++                     this.last_access = DateTime.UtcNow;
                }
   
                public byte [] DictionaryData {
                
                public void Touch ()
                {
---                     last_access = DateTime.Now;
+++                     last_access = DateTime.UtcNow;
                }
   
                public bool IsAbandoned () {
---                     if (last_access.AddMinutes (timeout) < DateTime.Now)
+++                     if (last_access.AddMinutes (timeout) < DateTime.UtcNow)
                                return true;
                        return false;
                }
                }
        }
   }
---
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..9e65355d77e7e1d5af93966527124728e31eaf01
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,161 @@@@
+++//
+++// System.Web.SessionState.HttpSessionState
+++//
+++// Authors:
+++//   Gonzalo Paniagua Javier (gonzalo@ximian.com)
+++//
+++// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
+++// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System.Collections;
+++using System.Collections.Specialized;
+++using System.Security.Permissions;
+++
+++namespace System.Web.SessionState {
+++
+++// CAS - no InheritanceDemand here as the class is sealed
+++[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+++public sealed class HttpSessionState : ICollection, IEnumerable
+++{
+++     IHttpSessionState container;
+++     
+++     internal HttpSessionState (IHttpSessionState container)
+++     {
+++             this.container = container;
+++     }
+++
+++     internal IHttpSessionState Container {
+++             get { return container; }
+++     }
+++     
+++     public int CodePage {
+++             get { return container.CodePage; }
+++             set { container.CodePage = value; }
+++     }
+++
+++     public HttpSessionState Contents {
+++             get { return this; }
+++     }
+++
+++     public int Count {
+++             get { return container.Count; }
+++     }
+++
+++     public bool IsCookieless {
+++             get { return container.IsCookieless; }
+++     }
+++
+++     public bool IsNewSession {
+++             get { return container.IsNewSession; }
+++     }
+++
+++     public bool IsReadOnly {
+++             get { return container.IsReadOnly; }
+++     }
+++
+++     public bool IsSynchronized {
+++             get { return container.IsSynchronized; }
+++     }
+++
+++     public object this [string key] {
+++             get { return container [key]; }
+++             set { container [key] = value; }
+++     }
+++
+++     public object this [int index] {
+++             get { return container [index]; }
+++             set { container [index] = value; }
+++     }
+++
+++     public NameObjectCollectionBase.KeysCollection Keys {
+++             get { return container.Keys; }
+++     }
+++
+++     public int LCID {
+++             get { return container.LCID; }
+++             set { container.LCID = value; }
+++     }
+++
+++     public SessionStateMode Mode {
+++             get { return container.Mode; }
+++     }
+++
+++     public string SessionID {
+++             get { return container.SessionID; }
+++     }
+++
+++     public HttpStaticObjectsCollection StaticObjects {
+++             get { return container.StaticObjects; }
+++     }
+++
+++     public object SyncRoot {
+++             get { return container.SyncRoot; }
+++     }
+++
+++     public int Timeout {
+++             get { return container.Timeout; }
+++             set { container.Timeout = value; }
+++     }
+++
+++     public void Abandon ()
+++     {
+++             container.Abandon ();
+++     }
+++
+++     public void Add (string name, object value)
+++     {
+++             container.Add (name, value);
+++     }
+++
+++     public void Clear ()
+++     {
+++             container.Clear ();
+++     }
+++     
+++     public void CopyTo (Array array, int index)
+++     {
+++             container.CopyTo (array, index);
+++     }
+++
+++     public IEnumerator GetEnumerator ()
+++     {
+++             return container.GetEnumerator ();
+++     }
+++     
+++     public void Remove (string name)
+++     {
+++             container.Remove (name);
+++     }
+++
+++     public void RemoveAll ()
+++     {
+++             container.Clear ();
+++     }
+++
+++     public void RemoveAt (int index)
+++     {
+++             container.RemoveAt (index);
+++     }
+++}
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..4877c061dbefe14f200474b70f4e1260f7c1c430
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,253 @@@@
+++//
+++// System.Web.Compilation.SessionStateItemCollection
+++//
+++// Authors:
+++//   Gonzalo Paniagua Javier (gonzalo@ximian.com)
+++//   Marek Habersack (grendello@gmail.com)
+++//
+++// (C) 2006 Marek Habersack
+++// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
+++// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System.Collections;
+++using System.Collections.Generic;
+++using System.Collections.Specialized;
+++using System.Globalization;
+++using System.Text;
+++using System.Threading;
+++using System.Web.Util;
+++
+++namespace System.Web.SessionState 
+++{
+++     public class HttpSessionStateContainer : IHttpSessionState
+++     {
+++             string id;
+++             HttpStaticObjectsCollection staticObjects;
+++             int timeout;
+++             bool newSession;
+++             bool isCookieless;
+++             SessionStateMode mode;
+++             bool isReadOnly;
+++             internal bool abandoned;
+++             ISessionStateItemCollection sessionItems;
+++             HttpCookieMode cookieMode;
+++             
+++             public HttpSessionStateContainer (string id,
+++                                               ISessionStateItemCollection sessionItems,
+++                                               HttpStaticObjectsCollection staticObjects,
+++                                               int timeout,
+++                                               bool newSession,
+++                                               HttpCookieMode cookieMode,
+++                                               SessionStateMode mode,
+++                                               bool isReadonly)
+++             {
+++                     if (id == null)
+++                             throw new ArgumentNullException ("id");
+++                     
+++                     this.sessionItems = sessionItems;
+++                     this.id = id;
+++                     this.staticObjects = staticObjects;
+++                     this.timeout = timeout;
+++                     this.newSession = newSession;
+++                     this.cookieMode = cookieMode;
+++                     this.mode = mode;
+++                     this.isReadOnly = isReadonly;
+++             }
+++             
+++             public int CodePage {
+++                     get {
+++                             HttpContext current = HttpContext.Current;
+++                             if (current == null)
+++                                     return Encoding.Default.CodePage;
+++
+++                             return current.Response.ContentEncoding.CodePage;
+++                     }
+++                     
+++                     set {
+++                             HttpContext current = HttpContext.Current;
+++                             if (current != null)
+++                                     current.Response.ContentEncoding = Encoding.GetEncoding (value);
+++                     }
+++             }
+++             
+++             public HttpCookieMode CookieMode {
+++                     get { return cookieMode; }
+++             }
+++             
+++             public int Count {
+++                     get {
+++                             if (sessionItems != null)
+++                                     return sessionItems.Count;
+++                             return 0;
+++                     }
+++             }
+++             
+++             public bool IsAbandoned {
+++                     get { return abandoned; }
+++             }
+++             
+++             public bool IsCookieless {
+++                     get { return isCookieless; }
+++             }
+++             
+++             public bool IsNewSession {
+++                     get { return newSession; }
+++             }
+++             
+++             public bool IsReadOnly {
+++                     get { return isReadOnly; }
+++             }
+++             
+++             public bool IsSynchronized {
+++                     get { return false; }
+++             }
+++             
+++             object IHttpSessionState.this [int index] {
+++                     get {
+++                             if (sessionItems == null || sessionItems.Count == 0)
+++                                     return null;
+++                             return sessionItems [index];
+++                     }
+++                     
+++                     set {
+++                             if (sessionItems != null)
+++                                     sessionItems [index] = value;
+++                     }
+++             }
+++             
+++                object IHttpSessionState.this [string name] {
+++                     get {
+++                             if (sessionItems == null || sessionItems.Count == 0)
+++                                     return null;
+++                             return sessionItems [name];
+++                     }
+++                     
+++                     set {
+++                             if (sessionItems != null)
+++                                     sessionItems [name] = value;
+++                     }
+++             }
+++             
+++             NameObjectCollectionBase.KeysCollection IHttpSessionState.Keys {
+++                     get {
+++                             if (sessionItems != null)
+++                                     return sessionItems.Keys;
+++                             return null;
+++                     }
+++             }
+++             
+++             public int LCID {
+++                     get { return Thread.CurrentThread.CurrentCulture.LCID; }
+++                     set { Thread.CurrentThread.CurrentCulture = new CultureInfo(value); }
+++             }
+++             
+++             public SessionStateMode Mode {
+++                     get { return mode; }
+++             }
+++             
+++             public string SessionID {
+++                     get { return id; }
+++             }
+++             
+++             public HttpStaticObjectsCollection StaticObjects {
+++                     get { return staticObjects; }
+++             }
+++             
+++             public Object SyncRoot {
+++                     get { return this; }
+++             }
+++             
+++             public int Timeout {
+++                     get { return timeout; }
+++                     set {
+++                             if (value < 1)
+++                                     throw new ArgumentException ("The argument to SetTimeout must be greater than 0.");
+++                             timeout = value;
+++                     }
+++             }
+++
+++             internal void SetNewSession (bool value)
+++             {
+++                     newSession = value;
+++             }
+++             
+++             public void Abandon ()
+++             {
+++                     abandoned = true;
+++             }
+++
+++             public void Add (string name, Object value)
+++             {
+++                     if (sessionItems == null)
+++                             return;
+++                     sessionItems [name] = value;
+++             }
+++
+++             public void Clear ()
+++             {
+++                     if (sessionItems == null)
+++                             return;
+++                     sessionItems.Clear ();
+++             }
+++
+++             public void CopyTo (Array array, int index)
+++             {
+++                     if (sessionItems == null)
+++                             return;
+++                     NameObjectCollectionBase.KeysCollection all = sessionItems.Keys;
+++                     for (int i = 0; i < all.Count; i++)
+++                             array.SetValue (all.Get(i), i + index);
+++             }
+++
+++             public IEnumerator GetEnumerator ()
+++             {
+++                     if (sessionItems == null)
+++                             return null;
+++                     return sessionItems.GetEnumerator ();
+++             }
+++             
+++             public void Remove (string name)
+++             {
+++                     if (sessionItems == null)
+++                             return;
+++                     sessionItems.Remove (name);
+++             }
+++
+++             public void RemoveAll ()
+++             {
+++                     if (sessionItems == null)
+++                             return;
+++                     sessionItems.Clear ();
+++             }
+++
+++             public void RemoveAt (int index)
+++             {
+++                     if (sessionItems == null)
+++                             return;
+++                     sessionItems.RemoveAt (index);
+++             }
+++     }
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..978208249d0a2f2b7d9e134453ed6b8e93a343de
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,69 @@@@
+++//
+++// System.Web.SessionState.IReadOnlySessionState
+++//
+++// Authors:
+++//   Sanjay Gupta (gsanjay@novell.com)
+++//
+++// (C) 2004 Novell, Inc (http://www.novell.com)
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++
+++#if NET_2_0
+++
+++using System.Collections;
+++using System.Collections.Specialized;
+++
+++namespace System.Web.SessionState {
+++     public interface IHttpSessionState
+++     {
+++             ///methods
+++             void Abandon ();
+++             void Add (string itemName, object itemValue);
+++             void Clear ();
+++             void CopyTo (Array sessionValues, int index);
+++             IEnumerator GetEnumerator ();
+++             void Remove (string itemName);
+++             void RemoveAll ();
+++             void RemoveAt (int index);
+++     
+++             ///properties
+++             int CodePage { get; set; }
+++             HttpCookieMode CookieMode { get; }
+++             int Count { get; }              
+++             bool IsCookieless { get; }
+++             bool IsNewSession { get; }
+++             bool IsReadOnly { get; }
+++             bool IsSynchronized { get; }
+++             object this [int index] { get; set; }
+++             object this [string name] { get; set;}
+++             NameObjectCollectionBase.KeysCollection Keys { get; }
+++             int LCID { get; set; }
+++             SessionStateMode Mode { get; }
+++             string SessionID { get; }
+++             HttpStaticObjectsCollection StaticObjects { get; }
+++             object SyncRoot { get; }
+++             int Timeout { get; set; }                       
+++     }
+++}
+++#endif
+++
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..d3742521a3e06dbf2a5395a6f47a458b94f63d88
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,50 @@@@
+++//
+++// System.Web.SessionState.ISessionIDManager
+++//
+++// Authors:
+++//   Sanjay Gupta (gsanjay@novell.com)
+++//
+++// (C) 2004 Novell, Inc (http://www.novell.com)
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++
+++#if NET_2_0
+++
+++using System;
+++using System.Web;
+++
+++namespace System.Web.SessionState {
+++     public interface ISessionIDManager
+++     {
+++             ///methods
+++             string CreateSessionID (HttpContext context);
+++             string GetSessionID (HttpContext context);
+++             void Initialize ();
+++             bool InitializeRequest (HttpContext context, bool suppressAutoDetectRedirect, out bool supportSessionIDReissue);
+++             void RemoveSessionID (HttpContext context);
+++             void SaveSessionID (HttpContext context, string sessionID, out bool isRedirected, out bool isCookieAdded);
+++             bool Validate (string id);
+++     }
+++}
+++#endif
+++
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..c76294f36e8a3b050f14e92295606891e4277057
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,51 @@@@
+++//
+++// System.Web.SessionState.ISessionStateItemCollection
+++//
+++// Authors:
+++//   Sanjay Gupta (gsanjay@novell.com)
+++//
+++// Copyright (c) 2004-2005 Novell, Inc (http://www.novell.com)
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++
+++#if NET_2_0
+++
+++using System.Collections;
+++using System.Collections.Specialized;
+++
+++namespace System.Web.SessionState {
+++
+++     public interface ISessionStateItemCollection : ICollection, IEnumerable
+++     {
+++             ///methods
+++             void Clear ();
+++             void Remove (string itemName);
+++             void RemoveAt (int index);
+++     
+++             ///properties
+++             bool Dirty { get; set; }
+++             object this [int index] { get; set; }
+++             object this [string name] { get; set;}
+++             NameObjectCollectionBase.KeysCollection Keys { get; }
+++     }
+++}
+++#endif
+++
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..5bbcf223c0d977ca8c07323659a376c13e28f575
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,216 @@@@
+++//
+++// System.Web.SessionState.RemoteStateServer
+++//
+++// Author(s):
+++//  Jackson Harper (jackson@ximian.com)
+++//  Gonzalo Paniagua (gonzalo@ximian.com)
+++//  Marek Habersack (grendello@gmail.com)
+++//
+++// (C) 2003-2006 Novell, Inc (http://www.novell.com)
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System;
+++using System.Threading;
+++using System.Web.Caching;
+++
+++namespace System.Web.SessionState {
+++     class LockableStateServerItem
+++     {
+++             public StateServerItem item;
+++             public ReaderWriterLock rwlock;
+++
+++             public LockableStateServerItem (StateServerItem item)
+++             {
+++                     this.item = item;
+++                     this.rwlock = new ReaderWriterLock ();
+++             }
+++     }
+++     
+++     internal class RemoteStateServer : MarshalByRefObject {
+++             const Int32 lockAcquireTimeout = 30000;
+++             Cache cache;
+++             
+++             internal RemoteStateServer ()
+++             {
+++                     cache = new Cache ();
+++             }
+++
+++             void Insert (string id, LockableStateServerItem item)
+++             {
+++                     cache.Insert (id, item, null, Cache.NoAbsoluteExpiration, new TimeSpan (0, item.item.Timeout, 0));
+++             }
+++
+++             LockableStateServerItem Retrieve (string id)
+++             {
+++                     return cache [id] as LockableStateServerItem;
+++             }
+++
+++             internal void CreateUninitializedItem (string id, int timeout)
+++             {
+++                     StateServerItem item = new StateServerItem (timeout);
+++                     item.Action = SessionStateActions.InitializeItem;
+++                     LockableStateServerItem cacheItem = new LockableStateServerItem (item);
+++                     Insert (id, cacheItem);
+++             }
+++             
+++             internal StateServerItem GetItem (string id,
+++                                               out bool locked,
+++                                               out TimeSpan lockAge,
+++                                               out object lockId,
+++                                               out SessionStateActions actions,
+++                                               bool exclusive)
+++             {
+++                     Console.WriteLine ("RemoteStateServer.GetItem");
+++                     Console.WriteLine ("\tid == {0}", id);
+++                     locked = false;
+++                     lockAge = TimeSpan.MinValue;
+++                     lockId = Int32.MinValue;
+++                     actions = SessionStateActions.None;
+++                     
+++                     LockableStateServerItem item = Retrieve (id);
+++                     if (item == null || item.item.IsAbandoned ()) {
+++                             Console.WriteLine ("\tNo item for that id (abandoned == {0})", item != null ? item.item.IsAbandoned() : false);
+++                             return null;
+++                     }
+++                     
+++                     try {
+++                             Console.WriteLine ("\tacquiring reader lock");
+++                             item.rwlock.AcquireReaderLock (lockAcquireTimeout);
+++                             if (item.item.Locked) {
+++                                     Console.WriteLine ("\titem is locked");
+++                                     locked = true;
+++                                     lockAge = DateTime.UtcNow.Subtract (item.item.LockedTime);
+++                                     lockId = item.item.LockId;
+++                                     return null;
+++                             }
+++                             Console.WriteLine ("\teleasing reader lock");
+++                             item.rwlock.ReleaseReaderLock ();
+++                             if (exclusive) {
+++                                     Console.WriteLine ("\tacquiring writer lock");
+++                                     item.rwlock.AcquireWriterLock (lockAcquireTimeout);
+++                                     Console.WriteLine ("\tlocking the item");
+++                                     item.item.Locked = true;
+++                                     item.item.LockedTime = DateTime.UtcNow;
+++                                     item.item.LockId++;
+++                                     Console.WriteLine ("\tnew lock id == {0}", item.item.LockId);
+++                                     lockId = item.item.LockId;
+++                             }
+++                     } catch {
+++                             throw;
+++                     } finally {
+++                             if (item.rwlock.IsReaderLockHeld) {
+++                                     Console.WriteLine ("\treleasing reader lock [finally]");
+++                                     item.rwlock.ReleaseReaderLock ();
+++                             }
+++                             if (item.rwlock.IsWriterLockHeld) {
+++                                     Console.WriteLine ("\treleasing writer lock [finally]");
+++                                     item.rwlock.ReleaseWriterLock ();
+++                             }
+++                     }
+++                     
+++                     Console.WriteLine ("\treturning an item");
+++                     actions = item.item.Action;
+++                     return item.item;
+++             }
+++
+++             internal void Remove (string id, object lockid)
+++             {
+++                     cache.Remove (id);
+++             }
+++
+++             internal void ResetItemTimeout (string id)
+++             {
+++                     LockableStateServerItem item = Retrieve (id);
+++                     if (item == null)
+++                             return;
+++                     item.item.Touch ();
+++             }
+++
+++             internal void ReleaseItemExclusive (string id, object lockId)
+++             {
+++                     LockableStateServerItem item = Retrieve (id);
+++                     if (item == null || item.item.LockId != (Int32)lockId)
+++                             return;
+++                     
+++                     try {
+++                             item.rwlock.AcquireWriterLock (lockAcquireTimeout);
+++                             item.item.Locked = false;
+++                     } catch {
+++                             throw;
+++                     } finally {
+++                             if (item.rwlock.IsWriterLockHeld)
+++                                     item.rwlock.ReleaseWriterLock ();
+++                     }
+++             }
+++             
+++             internal void SetAndReleaseItemExclusive (string id, byte [] collection_data, byte [] sobjs_data,
+++                                                       object lockId, int timeout, bool newItem)
+++             {
+++                     Console.WriteLine ("RemoteStateServer.SetAndReleaseItemExclusive");
+++                     Console.WriteLine ("\tid == {0}", id);
+++                     LockableStateServerItem item = Retrieve (id);
+++                     bool fresh = false;
+++                     
+++                     if (newItem || item == null) {
+++                             Console.WriteLine ("\tnew item");
+++                             item = new LockableStateServerItem (new StateServerItem (collection_data, sobjs_data, timeout));
+++                             item.item.LockId = (Int32)lockId;
+++                             fresh = true;
+++                     } else {
+++                             if (item.item.LockId != (Int32)lockId) {
+++                                     Console.WriteLine ("\tLockId mismatch ({0} != {1})", item.item.LockId, lockId);
+++                                     return;
+++                             }
+++                             Console.WriteLine ("\tremoving from cache");
+++                             Remove (id, lockId);
+++                     }
+++
+++                     try {
+++                             Console.WriteLine ("\tacquiring writer lock");
+++                             item.rwlock.AcquireWriterLock (lockAcquireTimeout);
+++                             item.item.Locked = false;
+++                             if (!fresh) {
+++                                     Console.WriteLine ("\tnot fresh = updating data");
+++                                     item.item.CollectionData = collection_data;
+++                                     item.item.StaticObjectsData = sobjs_data;
+++                             }
+++                             Console.WriteLine ("\tInserting in cache");
+++                             Insert (id, item);
+++                     } catch {
+++                             throw;
+++                     } finally {
+++                             if (item.rwlock.IsWriterLockHeld) {
+++                                     Console.WriteLine ("\treleasing writer lock [finally]");
+++                                     item.rwlock.ReleaseWriterLock ();
+++                             }
+++                     }
+++             }
+++             
+++             public override object InitializeLifetimeService ()
+++             {
+++                     return null; // just in case...
+++             }
+++     }
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..6971a1a8ee882b9d2feb118df5db62a39b2fdb13
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,137 @@@@
+++//
+++// System.Web.Compilation.SessionStateItemCollection
+++//
+++// Authors:
+++//   Marek Habersack (grendello@gmail.com)
+++//
+++// (C) 2006 Marek Habersack
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System.Security.Cryptography;
+++using System.Web;
+++using System.Web.Configuration;
+++using System.Web.Util;
+++
+++namespace System.Web.SessionState 
+++{
+++     public class SessionIDManager : ISessionIDManager
+++     {
+++             static SessionStateSection config;
+++             
+++             public SessionIDManager ()
+++             {
+++             }
+++
+++             public static int SessionIDMaxLength {
+++                     get { return 80; }
+++             }
+++
+++             // Todo: find use for the context parameter?
+++             public virtual string CreateSessionID (HttpContext context)
+++             {
+++                     return SessionId.Create ();
+++             }
+++
+++             public virtual string Decode (string id)
+++             {
+++                     return HttpUtility.UrlDecode (id);
+++             }
+++
+++             public virtual string Encode (string id)
+++             {
+++                     return HttpUtility.UrlEncode (id);
+++             }
+++             
+++             public string GetSessionID (HttpContext context)
+++             {
+++                     string ret = null;
+++
+++                     if (SessionStateModule.IsCookieLess (context)) {
+++                             string tmp = context.Request.Headers [SessionStateModule.HeaderName];
+++                             if (tmp != null)
+++                                     ret = Decode (tmp);
+++                     } else {
+++                             HttpCookie cookie = context.Request.Cookies [SessionStateModule.CookieName];
+++                             if (cookie != null)
+++                                     ret = Decode (cookie.Value);
+++                     }
+++                     
+++                     if (ret != null && ret.Length > SessionIDMaxLength)
+++                             throw new HttpException ("The length of the session-identifier value retrieved from the HTTP request exceeds the SessionIDMaxLength value.");
+++                     if (!Validate (ret))
+++                             throw new HttpException ("Invalid session ID");
+++                     
+++                     return ret;
+++             }
+++
+++             public void Initialize ()
+++             {
+++                     config = WebConfigurationManager.GetSection ("system.web/sessionState") as SessionStateSection;
+++             }
+++
+++             public bool InitializeRequest (HttpContext context, bool suppressAutoDetectRedirect, out bool supportSessionIDReissue)
+++             {
+++                     // TODO: Implement AutoDetect handling
+++                     if (config.CookieLess) {
+++                             supportSessionIDReissue = true;
+++                             return false;
+++                     } else {
+++                             supportSessionIDReissue = false;
+++                             return false;
+++                     }
+++             }
+++
+++             public void RemoveSessionID (HttpContext context)
+++             {
+++                     context.Response.Cookies.Remove(config.CookieName);
+++             }
+++
+++             // TODO: add code to check whether the response has already been sent
+++             public void SaveSessionID (HttpContext context, string id, out bool redirected, out bool cookieAdded)
+++             {
+++                     if (!Validate (id))
+++                             throw new HttpException ("Invalid session ID");
+++                     
+++                     if (!SessionStateModule.IsCookieLess (context)) {
+++                             HttpCookie cookie = new HttpCookie (config.CookieName, id);
+++                             cookie.Path = context.Request.ApplicationPath;
+++                             context.Response.AppendCookie (cookie);
+++                             cookieAdded = true;
+++                             redirected = false;
+++                     } else {
+++                             context.Request.SetHeader (SessionStateModule.HeaderName, id);
+++                             cookieAdded = false;
+++                             redirected = true;
+++                             string newUri = UrlUtils.InsertSessionId (id, context.Request.FilePath);
+++                             context.Response.Redirect (newUri, false);
+++                     }
+++             }
+++
+++             public virtual bool Validate (string id)
+++             {
+++                     return true;
+++             }
+++     }
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..bb4b147cacf66e05d882f8d3783b6b395fd13328
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,338 @@@@
+++//
+++// System.Web.SessionState.SessionInProcHandler
+++//
+++// Authors:
+++//   Marek Habersack <grendello@gmail.com
+++//
+++// (C) 2006 Marek Habersack
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System;
+++using System.IO;
+++using System.Collections;
+++using System.Collections.Specialized;
+++using System.Configuration.Provider;
+++using System.Web.Caching;
+++using System.Web.Configuration;
+++using System.Threading;
+++
+++namespace System.Web.SessionState
+++{
+++     internal sealed class InProcSessionItem
+++     {
+++             public bool locked;
+++             public bool cookieless;
+++             public ISessionStateItemCollection items;
+++             public DateTime lockedTime;
+++             public DateTime expiresAt;
+++             public ReaderWriterLock rwlock;
+++             public Int32 lockId;
+++             public int timeout;
+++             
+++             internal InProcSessionItem ()
+++             {
+++                     this.locked = false;
+++                     this.cookieless = false;
+++                     this.items = null;
+++                     this.lockedTime = DateTime.MinValue;
+++                     this.expiresAt = DateTime.MinValue;
+++                     this.rwlock = new ReaderWriterLock ();
+++                     this.lockId = Int32.MinValue;
+++                     this.timeout = 0;
+++             }
+++     }
+++     
+++     internal class SessionInProcHandler : SessionStateStoreProviderBase
+++     {
+++             private const string CachePrefix = "@@@InProc@";
+++             private const Int32 lockAcquireTimeout = 30000;
+++             
+++             CacheItemRemovedCallback removedCB;
+++             SessionStateSection config;
+++             NameValueCollection privateConfig;
+++             SessionStateItemExpireCallback expireCallback;
+++                     
+++             public SessionInProcHandler (SessionStateSection config)
+++             {
+++                     this.config = config;
+++             }
+++
+++             public override SessionStateStoreData CreateNewStoreData (HttpContext context, int timeout)
+++             {
+++                     return new SessionStateStoreData (new SessionStateItemCollection (),
+++                                                       SessionStateUtility.GetSessionStaticObjects(context),
+++                                                       timeout);
+++             }
+++
+++             void InsertSessionItem (InProcSessionItem item, int timeout, string id)
+++             {
+++                     HttpRuntime.Cache.InsertPrivate (id,
+++                                                      item,
+++                                                      null,
+++                                                      Cache.NoAbsoluteExpiration,
+++                                                      TimeSpan.FromMinutes (timeout),
+++                                                      CacheItemPriority.AboveNormal,
+++                                                      removedCB);
+++             }
+++             
+++             public override void CreateUninitializedItem (HttpContext context, string id, int timeout)
+++             {
+++                     EnsureGoodId (id, true);
+++                     InProcSessionItem item = new InProcSessionItem ();
+++                     item.expiresAt = DateTime.UtcNow.AddMinutes (timeout);
+++                     item.timeout = timeout;
+++                     InsertSessionItem (item, timeout, CachePrefix + id);
+++             }
+++             
+++             public override void Dispose ()
+++             {
+++             }
+++             
+++             public override void EndRequest (HttpContext context)
+++             {
+++             }
+++
+++             SessionStateStoreData GetItemInternal (HttpContext context,
+++                                                    string id,
+++                                                    out bool locked,
+++                                                    out TimeSpan lockAge,
+++                                                    out object lockId,
+++                                                    out SessionStateActions actions,
+++                                                    bool exclusive)
+++             {
+++                     locked = false;
+++                     lockAge = TimeSpan.MinValue;
+++                     lockId = Int32.MinValue;
+++                     actions = SessionStateActions.None;
+++
+++                     if (id == null)
+++                             return null;
+++                     
+++                     Cache cache = HttpRuntime.Cache;
+++                     string CacheId = CachePrefix + id;
+++                     InProcSessionItem item = cache [CacheId] as InProcSessionItem;
+++                     
+++                     if (item == null)
+++                             return null;
+++                     
+++                     try {
+++                             item.rwlock.AcquireReaderLock (lockAcquireTimeout);
+++                             if (item.locked) {
+++                                     locked = true;
+++                                     lockAge = DateTime.UtcNow.Subtract (item.lockedTime);
+++                                     lockId = item.lockId;
+++                                     return null;
+++                             }
+++                             item.rwlock.ReleaseReaderLock ();
+++                             if (exclusive) {
+++                                     item.rwlock.AcquireWriterLock (lockAcquireTimeout);
+++                                     item.locked = true;
+++                                     item.lockedTime = DateTime.UtcNow;
+++                                     item.lockId++;
+++                                     lockId = item.lockId;
+++                             }
+++                             if (item.items == null) {
+++                                     actions = SessionStateActions.InitializeItem;
+++                                     item.items = new SessionStateItemCollection ();
+++                             }
+++                             return new SessionStateStoreData (item.items,
+++                                                               SessionStateUtility.GetSessionStaticObjects(context),
+++                                                               item.timeout);
+++                     } catch {
+++                             // we want such errors to be passed to the application.
+++                             throw;
+++                     } finally {
+++                             if (item.rwlock.IsReaderLockHeld) 
+++                                     item.rwlock.ReleaseReaderLock ();
+++                             if (item.rwlock.IsWriterLockHeld) 
+++                                     item.rwlock.ReleaseWriterLock ();
+++                     }
+++             }
+++             
+++             public override SessionStateStoreData GetItem (HttpContext context,
+++                                                            string id,
+++                                                            out bool locked,
+++                                                            out TimeSpan lockAge,
+++                                                            out object lockId,
+++                                                            out SessionStateActions actions)
+++             {
+++                     EnsureGoodId (id, false);
+++                     return GetItemInternal (context, id, out locked, out lockAge, out lockId, out actions, false);
+++             }
+++             
+++             public override SessionStateStoreData GetItemExclusive (HttpContext context,
+++                                                                     string id,
+++                                                                     out bool locked,
+++                                                                     out TimeSpan lockAge,
+++                                                                     out object lockId,
+++                                                                     out SessionStateActions actions)
+++             {
+++                     EnsureGoodId (id, false);
+++                     return GetItemInternal (context, id, out locked, out lockAge, out lockId, out actions, true);
+++             }
+++
+++             public override void Initialize (string name, NameValueCollection config)
+++             {
+++                     if (String.IsNullOrEmpty (name))
+++                             name = "Session InProc handler";
+++                     removedCB = new CacheItemRemovedCallback (OnSessionRemoved);
+++                     privateConfig = config;
+++                     base.Initialize (name, config);
+++             }
+++             
+++             public override void InitializeRequest (HttpContext context)
+++             {
+++                     // nothing to do here
+++             }
+++             
+++             public override void ReleaseItemExclusive (HttpContext context,
+++                                                        string id,
+++                                                        object lockId)
+++             {
+++                     EnsureGoodId (id, true);
+++                     string CacheId = CachePrefix + id;
+++                     InProcSessionItem item = HttpRuntime.Cache [CacheId] as InProcSessionItem;
+++                     
+++                     if (item == null || lockId == null || lockId.GetType() != typeof(Int32) || item.lockId != (Int32)lockId)
+++                             return;
+++
+++                     try {
+++                             item.rwlock.AcquireWriterLock (lockAcquireTimeout);
+++                             item.locked = false;
+++                     } catch {
+++                             throw;
+++                     } finally {
+++                             if (item.rwlock.IsWriterLockHeld)
+++                                     item.rwlock.ReleaseWriterLock ();
+++                     }
+++             }
+++             
+++             public override void RemoveItem (HttpContext context,
+++                                              string id,
+++                                              object lockId,
+++                                              SessionStateStoreData item)
+++             {
+++                     EnsureGoodId (id, true);
+++                     string CacheId = CachePrefix + id;
+++                     Cache cache = HttpRuntime.Cache;
+++                     InProcSessionItem inProcItem = cache [CacheId] as InProcSessionItem;
+++
+++                     if (inProcItem == null || lockId == null || lockId.GetType() != typeof(Int32) || inProcItem.lockId != (Int32)lockId)
+++                             return;
+++
+++                     try {
+++                             inProcItem.rwlock.AcquireWriterLock (lockAcquireTimeout);
+++                             cache.Remove (CacheId);
+++                     } catch {
+++                             throw;
+++                     } finally {
+++                             if (inProcItem.rwlock.IsWriterLockHeld)
+++                                     inProcItem.rwlock.ReleaseWriterLock ();
+++                     }
+++             }
+++             
+++             public override void ResetItemTimeout (HttpContext context, string id)
+++             {
+++                     EnsureGoodId (id, true);
+++                     string CacheId = CachePrefix + id;
+++                     Cache cache = HttpRuntime.Cache;
+++                     InProcSessionItem item = cache [CacheId] as InProcSessionItem;
+++                     
+++                     if (item == null)
+++                             return;
+++
+++                     try {
+++                             item.rwlock.AcquireWriterLock (lockAcquireTimeout);
+++                             cache.Remove (CacheId);
+++                             InsertSessionItem (item, item.timeout, CacheId);
+++                     } catch {
+++                             throw;
+++                     } finally {
+++                             if (item.rwlock.IsWriterLockHeld)
+++                                     item.rwlock.ReleaseWriterLock ();
+++                     }
+++             }
+++             
+++             public override void SetAndReleaseItemExclusive (HttpContext context,
+++                                                              string id,
+++                                                              SessionStateStoreData item,
+++                                                              object lockId,
+++                                                              bool newItem)
+++             {
+++                     EnsureGoodId (id, true);
+++                     string CacheId = CachePrefix + id;
+++                     Cache cache = HttpRuntime.Cache;
+++                     InProcSessionItem inProcItem = cache [CacheId] as InProcSessionItem;
+++                     
+++                     if (newItem || inProcItem == null) {
+++                             inProcItem = new InProcSessionItem ();
+++                             inProcItem.timeout = item.Timeout;
+++                             inProcItem.expiresAt = DateTime.UtcNow.AddMinutes (item.Timeout);
+++                             if (lockId.GetType() == typeof(Int32))
+++                                     inProcItem.lockId = (Int32)lockId;
+++                     } else {
+++                             if (lockId == null || lockId.GetType() != typeof(Int32) || inProcItem.lockId != (Int32)lockId)
+++                                     return;
+++                             cache.Remove (CacheId);
+++                     }
+++                     
+++                     try {
+++                             inProcItem.rwlock.AcquireWriterLock (lockAcquireTimeout);
+++                             inProcItem.locked = false;
+++                             inProcItem.items = item.Items;
+++                             InsertSessionItem (inProcItem, item.Timeout, CacheId);
+++                     } catch {
+++                             throw;
+++                     } finally {
+++                             if (inProcItem.rwlock.IsWriterLockHeld)
+++                                     inProcItem.rwlock.ReleaseWriterLock ();
+++                     }
+++             }
+++             
+++             public override bool SetItemExpireCallback (SessionStateItemExpireCallback expireCallback)
+++             {
+++                     this.expireCallback = expireCallback;
+++                     return true;
+++             }
+++
+++             void EnsureGoodId (string id, bool throwOnNull)
+++             {
+++                     if (id == null)
+++                             if (throwOnNull)
+++                                     throw new HttpException ("Session ID is invalid");
+++                             else
+++                                     return;
+++                     
+++                     if (id.Length > SessionIDManager.SessionIDMaxLength)
+++                             throw new HttpException ("Session ID too long");
+++             }
+++
+++             void OnSessionRemoved (string key, object value, CacheItemRemovedReason reason)
+++                {
+++                     if (expireCallback != null)
+++                             expireCallback (key, value as SessionStateStoreData);
+++                }
+++     }
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..e71280e6ad1feea0785b8db4bb13d41b8b6fc5da
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,36 @@@@
+++//
+++// System.Web.Compilation.SessionStateItemCollection
+++//
+++// Authors:
+++//   Marek Habersack (grendello@gmail.com)
+++//
+++// (C) 2006 Marek Habersack
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System.Web;
+++
+++namespace System.Web.SessionState 
+++{
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..798769d8518c0224ae8a081111a015765f97d2bc
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,37 @@@@
+++//
+++// System.Web.SessionState.SessionStateActions.cs
+++//
+++// Authors:
+++//   Sanjay Gupta (gsanjay@novell.com)
+++//
+++// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++
+++#if NET_2_0
+++namespace System.Web.SessionState {
+++     public enum SessionStateActions {
+++             None = 0,
+++             InitializeItem  = 1
+++     }
+++}
+++#endif
+++
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..b5e946364febcda2127769a6213adedd667a4801
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,185 @@@@
+++//
+++// System.Web.Compilation.SessionStateItemCollection
+++//
+++// Authors:
+++//   Marek Habersack (grendello@gmail.com)
+++//
+++// (C) 2006 Marek Habersack
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System.Collections;
+++using System.Collections.Generic;
+++using System.Collections.Specialized;
+++using System.IO;
+++using System.Web.Util;
+++
+++namespace System.Web.SessionState 
+++{
+++     public sealed class SessionStateItemCollection : NameObjectCollectionBase, ISessionStateItemCollection, ICollection, IEnumerable
+++     {
+++             static Dictionary <Type, bool> immutables;
+++             bool is_dirty;
+++             
+++             static SessionStateItemCollection ()
+++             {
+++                     immutables = new Dictionary <Type, bool> (14);
+++                     Type type = typeof(string);
+++                     immutables.Add (type, true);
+++                     type = typeof(int);
+++                     immutables.Add (type, true);
+++                     type = typeof(bool);
+++                     immutables.Add (type, true);
+++                     type = typeof(decimal);
+++                     immutables.Add (type, true);
+++                     type = typeof(byte);
+++                     immutables.Add (type, true);
+++                     type = typeof(char);
+++                     immutables.Add (type, true);
+++                     type = typeof(float);
+++                     immutables.Add (type, true);
+++                     type = typeof(double);
+++                     immutables.Add (type, true);
+++                     type = typeof(sbyte);
+++                     immutables.Add (type, true);
+++                     type = typeof(short);
+++                     immutables.Add (type, true);
+++                     type = typeof(long);
+++                     immutables.Add (type, true);
+++                     type = typeof(ushort);
+++                     immutables.Add (type, true);
+++                     type = typeof(uint);
+++                     immutables.Add (type, true);
+++                     type = typeof(ulong);
+++                     immutables.Add (type, true);
+++             }
+++
+++             static bool IsMutable (object o)
+++             {
+++                     return (immutables.ContainsKey (o.GetType ()) == false);
+++             }
+++             
+++             public SessionStateItemCollection ()
+++             {
+++             }
+++
+++             internal SessionStateItemCollection (int capacity)
+++                     : base (capacity)
+++             {
+++             }
+++             
+++             public bool Dirty {
+++                     get { return is_dirty; }
+++                     set { is_dirty = value; }
+++             }
+++
+++             public object this [int index] {
+++                     get {
+++                             object o = BaseGet (index);
+++                             if (o != null && IsMutable (o))
+++                                     is_dirty = true;
+++                             return o;
+++                     }
+++                     
+++                     set {
+++                             BaseSet (index, value);
+++                             is_dirty = true;
+++                     }
+++             }
+++             
+++                public object this [string name] {
+++                     get {
+++                             object o = BaseGet (name);
+++                             if (o != null && IsMutable (o))
+++                                     is_dirty = true;
+++                             return o;
+++                     }
+++                     
+++                     set {
+++                             BaseSet (name, value);
+++                             is_dirty = true;
+++                     }
+++             }
+++
+++             // Todo: why override this?
+++             public override KeysCollection Keys {
+++                     get { return base.Keys; }
+++             }
+++
+++             public void Clear ()
+++             {
+++                     BaseClear ();
+++                     is_dirty = true;
+++             }
+++
+++             public static SessionStateItemCollection Deserialize (BinaryReader reader)
+++             {
+++                     int i = reader.ReadInt32 ();
+++                     SessionStateItemCollection ret = new SessionStateItemCollection (i);
+++                     while (i > 0) {
+++                             i--;
+++                             string key = reader.ReadString ();
+++                             int index = reader.ReadInt32 ();
+++                             if (index == AltSerialization.NullIndex)
+++                                     ret [key] = null;
+++                             else
+++                                     ret [key] = AltSerialization.DeserializeFromIndex (index, reader);
+++                     }
+++                     return ret;
+++             }
+++
+++             public void Serialize (BinaryWriter writer)
+++             {
+++                     lock (this) {
+++                             writer.Write (Count);
+++                             foreach (string key in base.Keys) {
+++                                     object val = BaseGet (key);
+++                                     if (val == null) {
+++                                             writer.Write (AltSerialization.NullIndex);
+++                                             continue;
+++                                     }
+++                                     AltSerialization.SerializeByType (writer, val);
+++                             }
+++                     }
+++             }
+++             
+++             // Todo: why override this?
+++             public override IEnumerator GetEnumerator ()
+++             {
+++                     return base.GetEnumerator ();
+++             }
+++
+++             public void Remove (string name)
+++             {
+++                     BaseRemove (name);
+++                     is_dirty = true;
+++             }
+++
+++             public void RemoveAt (int index)
+++             {
+++                     BaseRemoveAt (index);
+++                     is_dirty = true;
+++             }
+++     }
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..3b2c04d1c02704ae393f12ee2c2bca8d0b418ebf
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,38 @@@@
+++//
+++// System.Web.SessionState.SessionStateItemExpireCallback
+++//
+++// Authors:
+++//   Sanjay Gupta (gsanjay@novell.com)
+++//
+++// (C) 2004 Novell, Inc (http://www.novell.com)
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++
+++#if NET_2_0
+++namespace System.Web.SessionState
+++{
+++     public delegate void SessionStateItemExpireCallback (
+++                             string id, SessionStateStoreData item);
+++}
+++
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..2c7a17d23b9dfabaa01798916085733f1903308a
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,459 @@@@
+++//
+++// System.Web.SessionState.SesionStateModule
+++//
+++// Authors:
+++//   Gonzalo Paniagua Javier (gonzalo@ximian.com)
+++//   Stefan Görling (stefan@gorling.se)
+++//   Jackson Harper (jackson@ximian.com)
+++//      Marek Habersack (grendello@gmail.com)
+++//
+++// Copyright (C) 2002-2006 Novell, Inc (http://www.novell.com)
+++// (C) 2003 Stefan Görling (http://www.gorling.se)
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++
+++#if NET_2_0
+++using System.Collections.Specialized;
+++using System.Web.Configuration;
+++using System.Web.Caching;
+++using System.Web.Util;
+++using System.Security.Cryptography;
+++using System.Security.Permissions;
+++using System.Threading;
+++
+++namespace System.Web.SessionState
+++{
+++     class CallbackState
+++     {
+++             public HttpContext Context;
+++             public AutoResetEvent AutoEvent;
+++
+++             public CallbackState (HttpContext context, AutoResetEvent e)
+++             {
+++                     this.Context = context;
+++                     this.AutoEvent = e;
+++             }
+++     }
+++     
+++     // CAS - no InheritanceDemand here as the class is sealed
+++     [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+++     public sealed class SessionStateModule : IHttpModule
+++     {
+++             internal const string HeaderName = "AspFilterSessionId";
+++             internal const string CookielessFlagName = "_SessionIDManager_IsCookieLess";
+++             
+++             static object locker = new object ();
+++             
+++             internal static string CookieName {
+++                     get {
+++                             config = GetConfig ();
+++                             if (config == null)
+++                                     return null;
+++                             return config.CookieName;
+++                     }
+++             }
+++                             
+++#if TARGET_J2EE              
+++             static private SessionStateSection config {
+++                     get {
+++                             return (SessionStateSection) AppDomain.CurrentDomain.GetData ("SessionStateModule.config");
+++                     }
+++                     set {
+++                             AppDomain.CurrentDomain.SetData ("SessionStateModule.config", value);
+++                     }
+++             }
+++             
+++             static private Type handlerType
+++             {
+++                     get {
+++                             return (Type) AppDomain.CurrentDomain.GetData ("SessionStateModule.handlerType");
+++                     }
+++                     set {
+++                             AppDomain.CurrentDomain.SetData ("SessionStateModule.handlerType", value);
+++                     }
+++             }
+++             
+++             static private Type idManagerType
+++             {
+++                     get {
+++                             return (Type) AppDomain.CurrentDomain.GetData ("SessionStateModule.idManagerType");
+++                     }
+++                     set {
+++                             AppDomain.CurrentDomain.SetData ("SessionStateModule.idManagerType", value);
+++                     }
+++             }
+++#else
+++             static SessionStateSection config;
+++             static Type handlerType;
+++             static Type idManagerType;
+++#endif               
+++             SessionStateStoreProviderBase handler;
+++             ISessionIDManager idManager;
+++             HttpApplication app;
+++             
+++             // Store state
+++             bool storeLocked;
+++             TimeSpan storeLockAge;
+++             object storeLockId = new object();
+++             SessionStateActions storeSessionAction;
+++             SessionStateStoreData storeData;
+++
+++             // Session state
+++             bool isReadOnly;
+++             bool isNew;
+++             bool supportSessionIDReissue;
+++             bool supportsExpiration;
+++             string sessionId;
+++             HttpSessionStateContainer container;
+++             
+++             // config
+++             static TimeSpan executionTimeout;
+++             static int executionTimeoutMS;
+++
+++             [SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
+++             public SessionStateModule ()
+++             {
+++             }
+++
+++             public void Dispose ()
+++             {
+++                 if (handler!=null)
+++                     handler.Dispose();
+++             }
+++
+++             static SessionStateSection GetConfig ()
+++             {
+++                     lock (locker) {
+++                             if (config != null)
+++                                     return config;
+++
+++                             config = (SessionStateSection) WebConfigurationManager.GetSection ("system.web/sessionState");
+++                             SessionStateMode handlerMode = config.Mode;
+++                             
+++#if TARGET_J2EE
+++                             if (handlerMode == SessionStateMode.SQLServer || handlerMode == SessionStateMode.StateServer)
+++                                     throw new NotImplementedException("You must use web.xml to specify session state handling");
+++#endif
+++                             InitTypesFromConfig (config, handlerMode);
+++                             HttpRuntimeSection runtime = WebConfigurationManager.GetSection ("system.web/httpruntime") as HttpRuntimeSection;
+++                             if (runtime != null) {
+++                                     executionTimeout = runtime.ExecutionTimeout;
+++                                     executionTimeoutMS = executionTimeout.Milliseconds;
+++                             }
+++                             
+++                             return config;
+++                     }
+++             }
+++
+++             static void InitTypesFromConfig (SessionStateSection config, SessionStateMode handlerMode)
+++             {
+++                     if (handlerMode == SessionStateMode.StateServer)
+++                             handlerType = typeof (SessionStateServerHandler);
+++
+++//                   if (handlerMode == SessionStateMode.SQLServer)
+++//                           handlerType = typeof (SessionSQLServerHandler);
+++                     
+++                     if (handlerMode == SessionStateMode.InProc)
+++                             handlerType = typeof (SessionInProcHandler);
+++
+++                     if (handlerMode == SessionStateMode.Custom)
+++                             handlerType = GetCustomHandlerType (config);
+++                     
+++                     try {
+++                             idManagerType = Type.GetType (config.SessionIDManagerType, true);
+++                     } catch {
+++                             idManagerType = typeof (SessionIDManager);
+++                     } 
+++             }
+++
+++             static Type GetCustomHandlerType (SessionStateSection config)
+++             {
+++                     return null;
+++             }
+++             
+++             [EnvironmentPermission (SecurityAction.Assert, Read = "MONO_XSP_STATIC_SESSION")]
+++             public void Init (HttpApplication app)
+++             {
+++                     SessionStateSection cfg = GetConfig ();
+++                     this.app = app;
+++                     if (handlerType == null || idManagerType == null)
+++                             throw new HttpException ("Cannot initialize the session state module. Missing handler or ID manager types.");
+++                     app.BeginRequest += new EventHandler (OnBeginRequest);
+++                     app.AcquireRequestState += new EventHandler (OnAcquireRequestState);
+++                     app.ReleaseRequestState += new EventHandler (OnReleaseRequestState);
+++                     app.EndRequest += new EventHandler (OnEndRequest);
+++
+++                     if (handler == null) {
+++                             try {
+++                                     handler = Activator.CreateInstance (handlerType, new object [] {cfg}) as SessionStateStoreProviderBase;
+++                                     handler.Initialize (GetHandlerName (), GetHandlerConfig ());
+++                             } catch (Exception ex) {
+++                                     throw new HttpException ("Failed to initialize session storage provider.", ex);
+++                             }
+++                     }
+++
+++                     if (idManager == null) {
+++                             try {
+++                                     idManager = Activator.CreateInstance (idManagerType) as ISessionIDManager;
+++                                     idManager.Initialize ();
+++                             } catch (Exception ex) {
+++                                     throw new HttpException ("Failed to initialize session ID manager.", ex);
+++                             }
+++                     }
+++             }
+++
+++             string GetHandlerName ()
+++             {
+++                     switch (config.Mode) {
+++                             case SessionStateMode.InProc:
+++                             case SessionStateMode.StateServer:
+++                             case SessionStateMode.SQLServer:
+++                                     return null; // set by the handler
+++
+++                             case SessionStateMode.Custom:
+++                                     return "Custom Session State Handler";
+++
+++                             default:
+++                                     throw new HttpException ("Unknown session handler mode.");
+++                     }
+++             }
+++
+++             NameValueCollection GetHandlerConfig ()
+++             {
+++                     switch (config.Mode) {
+++                             case SessionStateMode.InProc:
+++                             case SessionStateMode.StateServer:
+++                             case SessionStateMode.SQLServer:
+++                                     return new NameValueCollection ();
+++
+++                             // TODO: implement
+++                             case SessionStateMode.Custom:
+++                                     return new NameValueCollection ();
+++
+++                             default:
+++                                     throw new HttpException ("Unknown session handler mode.");
+++                     }
+++             }
+++
+++             internal static bool IsCookieLess (HttpContext context)
+++                {
+++                        if (config.Cookieless == HttpCookieMode.UseCookies)
+++                                return false;
+++                     if (config.Cookieless == HttpCookieMode.UseUri)
+++                             return true;
+++                        object cookieless = context.Items [CookielessFlagName];
+++                        if (cookieless == null)
+++                                return false;
+++                        return (bool)cookieless;
+++                }
+++             
+++             void OnBeginRequest (object o, EventArgs args)
+++             {
+++                     HttpApplication application = (HttpApplication) o;
+++                     HttpContext context = application.Context;
+++                     string base_path = context.Request.BaseVirtualDir;
+++                     string id = UrlUtils.GetSessionId (base_path);
+++
+++                     if (id == null)
+++                             return;
+++                     
+++                     string new_path = UrlUtils.RemoveSessionId (base_path, context.Request.FilePath);
+++                     context.Request.SetFilePath (new_path);
+++                     context.Request.SetHeader (HeaderName, id);
+++                     context.Response.SetAppPathModifier (String.Concat ("(", id, ")"));
+++             }
+++
+++             void OnAcquireRequestState (object o, EventArgs args)
+++             {
+++                     Console.WriteLine ("SessionStateModule.OnAcquireRequestState (hash {0})", this.GetHashCode ().ToString ("x"));
+++                     HttpApplication application = (HttpApplication) o;
+++                     HttpContext context = application.Context;
+++
+++                     if (!(context.Handler is IRequiresSessionState)) {
+++                             Console.WriteLine ("Handler ({0}) does not require session state", context.Handler);
+++                             return;
+++                     }
+++                     isReadOnly = (context.Handler is IReadOnlySessionState);                        
+++                     
+++                     if (idManager != null) {
+++                             if (idManager.InitializeRequest (context, false, out supportSessionIDReissue))
+++                                     return; // Redirected, will come back here in a while
+++                             sessionId = idManager.GetSessionID (context);
+++                     }
+++                     
+++                     if (handler != null) {
+++                             handler.InitializeRequest (context);
+++                             GetStoreData (context);
+++                             if (storeData == null && !storeLocked) {
+++                                     isNew = true;
+++                                     sessionId = idManager.CreateSessionID (context);
+++                                     Console.WriteLine ("New session ID allocated: {0}", sessionId);
+++                                     bool redirected = false;
+++                                     bool cookieAdded = false;
+++                                     idManager.SaveSessionID (context, sessionId, out redirected, out cookieAdded);
+++                                     if (redirected) {
+++                                             if (supportSessionIDReissue)
+++                                                     handler.CreateUninitializedItem (context, sessionId, config.Timeout.Minutes);
+++                                             context.Response.End();
+++                                             return;
+++                                     } else
+++                                             storeData = handler.CreateNewStoreData (context, config.Timeout.Minutes);
+++                             } else if (storeData == null && storeLocked) {
+++                                     WaitForStoreUnlock (context);
+++                             } else if (storeData != null &&
+++                                        !storeLocked &&
+++                                        storeSessionAction == SessionStateActions.InitializeItem &&
+++                                        IsCookieLess (context)) {
+++                                     storeData = handler.CreateNewStoreData (context, config.Timeout.Minutes);
+++                             }
+++                             
+++                             SessionSetup (context, isNew);
+++                     }
+++             }
+++             
+++             void OnReleaseRequestState (object o, EventArgs args)
+++             {
+++                     Console.WriteLine ("SessionStateModule.OnReleaseRequestState (hash {0})", this.GetHashCode ().ToString ("x"));
+++                     Console.WriteLine ("\tsessionId == {0}", sessionId);
+++                     if (handler == null)
+++                             return;
+++
+++                     HttpApplication application = (HttpApplication) o;
+++                     HttpContext context = application.Context;
+++                     if (!(context.Handler is IRequiresSessionState))
+++                             return;
+++                     Console.WriteLine ("\trequest path == {0}", context.Request.FilePath);
+++                     Console.WriteLine ("\tHandler ({0}) requires session state", context.Handler);
+++                     
+++                     if (!container.IsAbandoned) {
+++                             Console.WriteLine ("\tnot abandoned");
+++                             if (!isReadOnly) {
+++                                     Console.WriteLine ("\tnot read only, storing and releasing");
+++                                     handler.SetAndReleaseItemExclusive (context, sessionId, storeData, storeLockId, false);
+++                             } else {
+++                                     Console.WriteLine ("\tread only, releasing");
+++                                     handler.ReleaseItemExclusive (context, sessionId, storeLockId);
+++                             }
+++                             handler.ResetItemTimeout (context, sessionId);
+++                     } else {
+++                             handler.ReleaseItemExclusive (context, sessionId, storeLockId);
+++                             handler.RemoveItem (context, sessionId, storeLockId, storeData);
+++                     }
+++                     SessionStateUtility.RemoveHttpSessionStateFromContext (context);
+++                     if (supportsExpiration)
+++                             SessionStateUtility.RaiseSessionEnd (container, o, args);
+++             }
+++
+++             void OnEndRequest (object o, EventArgs args)
+++             {
+++                     if (handler == null)
+++                             return;
+++                     
+++                     HttpApplication application = o as HttpApplication;
+++                     if (application == null)
+++                             return;
+++                     if (handler != null)
+++                             handler.EndRequest (application.Context);
+++             }
+++
+++             void GetStoreData (HttpContext context)
+++             {
+++                     if (sessionId == null)
+++                             return;
+++                     
+++                     if (isReadOnly)
+++                             storeData = handler.GetItem (context,
+++                                                          sessionId,
+++                                                          out storeLocked,
+++                                                          out storeLockAge,
+++                                                          out storeLockId,
+++                                                          out storeSessionAction);
+++                     else
+++                             storeData = handler.GetItemExclusive (context,
+++                                                                   sessionId,
+++                                                                   out storeLocked,
+++                                                                   out storeLockAge,
+++                                                                   out storeLockId,
+++                                                                   out storeSessionAction);
+++             }
+++             
+++             void WaitForStoreUnlock (HttpContext context)
+++             {
+++                     AutoResetEvent are = new AutoResetEvent (false);
+++                     TimerCallback tc = new TimerCallback (this.StoreUnlockWaitCallback);
+++                     CallbackState cs = new CallbackState (context, are);
+++                     using (Timer timer = new Timer (tc, cs, 500, 500)) {
+++                             try {
+++                                     are.WaitOne (executionTimeout, false);
+++                             } catch {
+++                                     storeData = null;
+++                             }
+++                     }
+++             }
+++
+++             void StoreUnlockWaitCallback (object s)
+++             {
+++                     CallbackState state = s as CallbackState;
+++                     GetStoreData (state.Context);
+++                     if (storeData == null && storeLocked && (storeLockAge > executionTimeout)) {
+++                             handler.ReleaseItemExclusive (state.Context, sessionId, storeLockId);
+++                             state.AutoEvent.Set ();
+++                     } else if (storeData != null && !storeLocked)
+++                             state.AutoEvent.Set ();
+++             }
+++             
+++             void SessionSetup (HttpContext context, bool isNew)
+++             {
+++                     if (storeData != null && sessionId != null) {
+++                             container = new HttpSessionStateContainer (
+++                                     sessionId,
+++                                     storeData.Items,
+++                                     storeData.StaticObjects,
+++                                     storeData.Timeout,
+++                                     isNew,
+++                                     config.Cookieless,
+++                                     config.Mode,
+++                                     isReadOnly);
+++                             SessionStateUtility.AddHttpSessionStateToContext (context, container);
+++                             if (isNew) {
+++                                     supportsExpiration = handler.SetItemExpireCallback (OnSessionExpired);
+++                                     OnSessionStart ();
+++                             }
+++                     }
+++             }
+++
+++             void OnSessionExpired (string id, SessionStateStoreData item)
+++             {
+++             }
+++             
+++             void OnSessionStart ()
+++             {
+++                     if (Start != null)
+++                             Start (this, EventArgs.Empty);
+++             }
+++             
+++             public event EventHandler Start;
+++
+++             // This event is public, but only Session_[On]End in global.asax will be invoked if present.
+++             public event EventHandler End;
+++     }
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..e21bab030757424a39a459f945b7d2abae6b4375
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,266 @@@@
+++//
+++// System.Web.Compilation.SessionStateItemCollection
+++//
+++// Authors:
+++//   Marek Habersack (grendello@gmail.com)
+++//
+++// (C) 2006 Marek Habersack
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System.Collections.Specialized;
+++using System.IO;
+++using System.Web;
+++using System.Web.Configuration;
+++using System.Runtime.Remoting;
+++
+++namespace System.Web.SessionState 
+++{
+++     internal class SessionStateServerHandler : SessionStateStoreProviderBase
+++     {
+++             private const Int32 lockAcquireTimeout = 30000;
+++             
+++             SessionStateSection config;
+++             NameValueCollection privateConfig;
+++             RemoteStateServer stateServer;
+++             
+++             public SessionStateServerHandler (SessionStateSection config)
+++             {
+++                     this.config = config;
+++             }
+++
+++             public override SessionStateStoreData CreateNewStoreData (HttpContext context, int timeout)
+++             {
+++                     return new SessionStateStoreData (new SessionStateItemCollection (),
+++                                                       SessionStateUtility.GetSessionStaticObjects(context),
+++                                                       timeout);
+++             }
+++             
+++             public override void CreateUninitializedItem (HttpContext context, string id, int timeout)
+++             {
+++                     EnsureGoodId (id, true);
+++                     stateServer.CreateUninitializedItem (id, timeout);
+++             }
+++             
+++             public override void Dispose ()
+++             {
+++             }
+++             
+++             public override void EndRequest (HttpContext context)
+++             {
+++             }
+++
+++             SessionStateStoreData GetItemInternal (HttpContext context,
+++                                                    string id,
+++                                                    out bool locked,
+++                                                    out TimeSpan lockAge,
+++                                                    out object lockId,
+++                                                    out SessionStateActions actions,
+++                                                    bool exclusive)
+++             {
+++                     Console.WriteLine ("SessionStateServerHandler.GetItemInternal");
+++                     Console.WriteLine ("\tid == {0}", id);
+++                     Console.WriteLine ("\tpath == {0}", context.Request.FilePath);
+++                     locked = false;
+++                     lockAge = TimeSpan.MinValue;
+++                     lockId = Int32.MinValue;
+++                     actions = SessionStateActions.None;
+++
+++                     if (id == null)
+++                             return null;
+++                     
+++                     StateServerItem item = stateServer.GetItem (id,
+++                                                                 out locked,
+++                                                                 out lockAge,
+++                                                                 out lockId,
+++                                                                 out actions,
+++                                                                 exclusive);
+++                     
+++                     if (item == null) {
+++                             Console.WriteLine ("\titem is null (locked == {0}, actions == {1})", locked, actions);
+++                             return null;
+++                     }
+++                     if (actions == SessionStateActions.InitializeItem) {
+++                             Console.WriteLine ("\titem needs initialization");
+++                             return CreateNewStoreData (context, item.Timeout);
+++                     }
+++                     SessionStateItemCollection items = null;
+++                     HttpStaticObjectsCollection sobjs = null;
+++                     MemoryStream stream = null;
+++                     BinaryReader reader = null;
+++                     try {
+++                             if (item.CollectionData != null && item.CollectionData.Length > 0) {
+++                                     stream = new MemoryStream (item.CollectionData);
+++                                     reader = new BinaryReader (stream);
+++                                     items = SessionStateItemCollection.Deserialize (reader);
+++                             } else
+++                                     items = new SessionStateItemCollection ();
+++                             if (item.StaticObjectsData != null && item.StaticObjectsData.Length > 0)
+++                                     sobjs = HttpStaticObjectsCollection.FromByteArray (item.StaticObjectsData);
+++                             else
+++                                     sobjs = new HttpStaticObjectsCollection ();
+++                     } catch (Exception ex) {
+++                             throw new HttpException ("Failed to retrieve session state.", ex);
+++                     } finally {
+++                             if (reader != null)
+++                                     reader.Close ();
+++                     }
+++                             
+++                     return new SessionStateStoreData (items,
+++                                                       sobjs,
+++                                                       item.Timeout);
+++             }
+++             
+++             public override SessionStateStoreData GetItem (HttpContext context,
+++                                                            string id,
+++                                                            out bool locked,
+++                                                            out TimeSpan lockAge,
+++                                                            out object lockId,
+++                                                            out SessionStateActions actions)
+++             {
+++                     EnsureGoodId (id, false);
+++                     return GetItemInternal (context, id, out locked, out lockAge, out lockId, out actions, false);
+++             }
+++             
+++             public override SessionStateStoreData GetItemExclusive (HttpContext context,
+++                                                                     string id,
+++                                                                     out bool locked,
+++                                                                     out TimeSpan lockAge,
+++                                                                     out object lockId,
+++                                                                     out SessionStateActions actions)
+++             {
+++                     EnsureGoodId (id, false);
+++                     return GetItemInternal (context, id, out locked, out lockAge, out lockId, out actions, true);
+++             }
+++
+++             public override void Initialize (string name, NameValueCollection config)
+++             {
+++                     Console.WriteLine ("SessionStateServerHandler.Initialize");
+++                     if (String.IsNullOrEmpty (name))
+++                             name = "Session Server handler";
+++                     privateConfig = config;
+++                     RemotingConfiguration.Configure (null);
+++                     string cons = null, proto = null, server = null, port = null;
+++                        GetConData (out proto, out server, out port);
+++                        cons = String.Format ("{0}://{1}:{2}/StateServer", proto, server, port);
+++                        stateServer = Activator.GetObject (typeof (RemoteStateServer), cons) as RemoteStateServer;
+++                     base.Initialize (name, config);
+++             }
+++             
+++             public override void InitializeRequest (HttpContext context)
+++             {
+++                     // nothing to do here
+++             }
+++             
+++             public override void ReleaseItemExclusive (HttpContext context,
+++                                                        string id,
+++                                                        object lockId)
+++             {
+++                     EnsureGoodId (id, true);
+++                     stateServer.ReleaseItemExclusive (id, lockId);
+++             }
+++             
+++             public override void RemoveItem (HttpContext context,
+++                                              string id,
+++                                              object lockId,
+++                                              SessionStateStoreData item)
+++             {
+++                     EnsureGoodId (id, true);
+++                     stateServer.Remove (id, lockId);
+++             }
+++             
+++             public override void ResetItemTimeout (HttpContext context, string id)
+++             {
+++                     EnsureGoodId (id, true);
+++                     stateServer.ResetItemTimeout (id);
+++             }
+++             
+++             public override void SetAndReleaseItemExclusive (HttpContext context,
+++                                                              string id,
+++                                                              SessionStateStoreData item,
+++                                                              object lockId,
+++                                                              bool newItem)
+++             {
+++                     EnsureGoodId (id, true);
+++                     byte[] collection_data = null;
+++                     byte[] sobjs_data = null;
+++                     MemoryStream stream = null;
+++                     BinaryWriter writer = null;
+++                     
+++                     try {
+++                             SessionStateItemCollection items = item.Items as SessionStateItemCollection;
+++                             if (items != null && items.Count > 0) {
+++                                     stream = new MemoryStream ();
+++                                     writer = new BinaryWriter (stream);
+++                                     items.Serialize (writer);
+++                                     collection_data = stream.GetBuffer ();
+++                             }
+++                             HttpStaticObjectsCollection sobjs = item.StaticObjects;
+++                             if (sobjs != null && sobjs.Count > 0)
+++                                     sobjs_data = sobjs.ToByteArray ();
+++                     } catch (Exception ex) {
+++                             throw new HttpException ("Failed to store session data.", ex);
+++                     } finally {
+++                             if (writer != null)
+++                                     writer.Close ();
+++                     }
+++                     
+++                     stateServer.SetAndReleaseItemExclusive (id, collection_data, sobjs_data, lockId, item.Timeout, newItem);
+++             }
+++             
+++             public override bool SetItemExpireCallback (SessionStateItemExpireCallback expireCallback)
+++             {
+++                     return false;
+++             }
+++
+++             void EnsureGoodId (string id, bool throwOnNull)
+++             {
+++                     if (id == null)
+++                             if (throwOnNull)
+++                                     throw new HttpException ("Session ID is invalid");
+++                             else
+++                                     return;
+++                     
+++                     if (id.Length > SessionIDManager.SessionIDMaxLength)
+++                             throw new HttpException ("Session ID too long");
+++             }
+++
+++             void GetConData (out string proto, out string server, out string port)
+++                {
+++                     string cons = config.StateConnectionString;
+++                        int ei = cons.IndexOf ('=');
+++                        int ci = cons.IndexOf (':');
+++
+++                        if (ei < 0 || ci < 0)
+++                                throw new HttpException ("Invalid StateConnectionString");
+++                        
+++                        proto = cons.Substring (0, ei);
+++                        server = cons.Substring (ei+1, ci - ei - 1);
+++                        port = cons.Substring (ci+1, cons.Length - ci - 1);
+++                     
+++                        if (proto == "tcpip")
+++                                proto = "tcp";
+++                }
+++     }
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..b2b57ddd18260770422c91f0c9464f6476f7357d
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,66 @@@@
+++//
+++// System.Web.SessionState.SessionStateStoreData.cs
+++//
+++// Authors:
+++//   Sanjay Gupta (gsanjay@novell.com)
+++//
+++// (C) 2004 Novell, Inc (http://www.novell.com)
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++
+++#if NET_2_0
+++
+++using System.Web;
+++
+++namespace System.Web.SessionState {
+++     public class SessionStateStoreData 
+++     {
+++             ISessionStateItemCollection sessionItems;
+++             HttpStaticObjectsCollection staticObjects;
+++             int timeout;
+++
+++             internal SessionStateStoreData (ISessionStateItemCollection items,
+++                                             HttpStaticObjectsCollection objects,
+++                                             int timeout)
+++             {
+++                     sessionItems = items;
+++                     staticObjects = objects;
+++                     this.timeout = timeout;
+++             }
+++
+++             public virtual ISessionStateItemCollection Items { 
+++                     get { return sessionItems ; }
+++             }
+++
+++             public virtual HttpStaticObjectsCollection StaticObjects { 
+++                     get { return staticObjects; }
+++             }
+++
+++             public virtual int Timeout { 
+++                     get { return timeout; }
+++                     set { timeout = value; }
+++             }
+++     }               
+++}
+++
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..809f4e4795481d8a4b452bba28db657ed29f697c
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,75 @@@@
+++//
+++// System.Web.Compilation.SessionStateItemCollection
+++//
+++// Authors:
+++//   Marek Habersack (grendello@gmail.com)
+++//
+++// (C) 2006 Marek Habersack
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System.Configuration.Provider;
+++using System.Web;
+++
+++namespace System.Web.SessionState 
+++{
+++     public abstract class SessionStateStoreProviderBase : ProviderBase
+++     {
+++             protected SessionStateStoreProviderBase ()
+++             {
+++             }
+++
+++             public abstract SessionStateStoreData CreateNewStoreData (HttpContext context, int timeout);
+++             public abstract void CreateUninitializedItem (HttpContext context, string id, int timeout);
+++             public abstract void Dispose ();
+++             public abstract void EndRequest (HttpContext context);
+++             public abstract SessionStateStoreData GetItem (HttpContext context,
+++                                                            string id,
+++                                                            out bool locked,
+++                                                            out TimeSpan lockAge,
+++                                                            out Object lockId,
+++                                                            out SessionStateActions actions);
+++             public abstract SessionStateStoreData GetItemExclusive (HttpContext context,
+++                                                                     string id,
+++                                                                     out bool locked,
+++                                                                     out TimeSpan lockAge,
+++                                                                     out Object lockId,
+++                                                                     out SessionStateActions actions);
+++             public abstract void InitializeRequest (HttpContext context);
+++             public abstract void ReleaseItemExclusive (HttpContext context,
+++                                                        string id,
+++                                                        Object lockId);
+++             public abstract void RemoveItem (HttpContext context,
+++                                              string id,
+++                                              Object lockId,
+++                                              SessionStateStoreData item);
+++             public abstract void ResetItemTimeout (HttpContext context, string id);
+++             public abstract void SetAndReleaseItemExclusive (HttpContext context,
+++                                                              string id,
+++                                                              SessionStateStoreData item,
+++                                                              Object lockId,
+++                                                              bool newItem);
+++             public abstract bool SetItemExpireCallback (SessionStateItemExpireCallback expireCallback);
+++     }
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..fad2919a1f3e8e7a194debcc7d26b9a11fb2a3a3
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,77 @@@@
+++//
+++// System.Web.Compilation.SessionStateItemCollection
+++//
+++// Authors:
+++//   Marek Habersack (grendello@gmail.com)
+++//
+++// (C) 2006 Marek Habersack
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++namespace System.Web.SessionState 
+++{
+++     public static class SessionStateUtility
+++     {
+++             public static void AddHttpSessionStateToContext (HttpContext context, IHttpSessionState container)
+++             {
+++                     if (context == null || container == null)
+++                             return;
+++                     if (context.Session != null)
+++                             throw new HttpException ("An HttpSessionState object for the current session has already been added to the specified context.");
+++                     
+++                     HttpSessionState state = new HttpSessionState (container);
+++                     context.SetSession (state);
+++             }
+++
+++             public static IHttpSessionState GetHttpSessionStateFromContext (HttpContext context)
+++             {
+++                     HttpSessionState session;
+++                     if (context == null || (session = context.Session) == null)
+++                             return null;
+++                     
+++                     return session.Container;
+++             }
+++
+++             public static HttpStaticObjectsCollection GetSessionStaticObjects (HttpContext context)
+++             {
+++                     HttpSessionState session;
+++                     if (context == null || (session = context.Session) == null)
+++                             return null;
+++                     return session.Container.StaticObjects;
+++             }
+++             
+++             public static void RaiseSessionEnd (IHttpSessionState session, Object eventSource, EventArgs eventArgs)
+++             {
+++                     HttpSessionState state = new HttpSessionState (session);
+++                     HttpApplicationFactory.InvokeSessionEnd (state, eventSource, eventArgs);
+++             }
+++
+++             public static void RemoveHttpSessionStateFromContext (HttpContext context)
+++             {
+++                     if (context == null)
+++                             return;
+++                     context.SetSession (null);
+++             }
+++     }
+++}
+++#endif
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..ebbe7cb148033e1dcc7cc2f841412312012146a9
new file mode 100644 (file)
--- /dev/null
--- /dev/null
--- /dev/null
@@@@ -1,0 -1,0 -1,0 +1,74 @@@@
+++//
+++// System.Web.SessionState.StateServerItem
+++//
+++// Author(s):
+++//  Jackson Harper (jackson@ximian.com)
+++//  Marek Habersack (grendello@gmail.com)
+++//
+++// (C) 2003 Novell, Inc (http://www.novell.com)
+++//
+++
+++//
+++// Permission is hereby granted, free of charge, to any person obtaining
+++// a copy of this software and associated documentation files (the
+++// "Software"), to deal in the Software without restriction, including
+++// without limitation the rights to use, copy, modify, merge, publish,
+++// distribute, sublicense, and/or sell copies of the Software, and to
+++// permit persons to whom the Software is furnished to do so, subject to
+++// the following conditions:
+++// 
+++// The above copyright notice and this permission notice shall be
+++// included in all copies or substantial portions of the Software.
+++// 
+++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+++//
+++#if NET_2_0
+++using System;
+++
+++namespace System.Web.SessionState {
+++     [Serializable]
+++     internal class StateServerItem {
+++             public byte [] CollectionData;
+++             public byte [] StaticObjectsData;
+++             DateTime last_access;
+++             public int Timeout;
+++             public Int32 LockId;
+++             public bool Locked;
+++             public DateTime LockedTime;
+++             public SessionStateActions Action;
+++
+++             public StateServerItem (int timeout) : this (null, null, timeout)
+++             {
+++             }
+++             
+++             public StateServerItem (byte [] collection_data, byte [] sobjs_data, int timeout)
+++             {
+++                     this.CollectionData = collection_data;
+++                     this.StaticObjectsData = sobjs_data;
+++                     this.Timeout = timeout;
+++                     this.last_access = DateTime.UtcNow;
+++                     this.Locked = false;
+++                     this.LockId = Int32.MinValue;
+++                     this.LockedTime = DateTime.MinValue;
+++                     this.Action = SessionStateActions.None;
+++             }
+++             
+++             public void Touch ()
+++             {
+++                     last_access = DateTime.UtcNow;
+++             }
+++
+++             public bool IsAbandoned () {
+++                     if (last_access.AddMinutes (Timeout) < DateTime.UtcNow)
+++                             return true;
+++                     return false;
+++             }
+++     }
+++}
+++#endif
index 60daf4a2bc051516a34b658173ff8958d8b8f6c0,60daf4a2bc051516a34b658173ff8958d8b8f6c0,60daf4a2bc051516a34b658173ff8958d8b8f6c0..86679099ebdb35a35a95bb59e9b55508cd81d4f5
@@@@ -124,6 -124,6 -124,6 +124,9 @@@@ namespace System.Web.UI 
                
                internal void AddApplicationAssembly ()
                {
+++                     if (Context.ApplicationInstance == null)
+++                                return; // this may happen if we have Global.asax and have
+++                                        // controls registered from Web.Config
                        string location = Context.ApplicationInstance.AssemblyLocation;
                        if (location != typeof (TemplateParser).Assembly.Location) {
                                appAssemblyIndex = assemblies.Add (location);
index 0ba104249555077383f0d13610bf40bc2e72a426,80e6adcbf58443ec723929da5aa2f6ca90953a7f,80e6adcbf58443ec723929da5aa2f6ca90953a7f..b9f780053e19f707914d15f220f374e5746d919c
@@@@ -402,12 -402,12 -402,12 +402,9 @@@@ System.Web.Security/WindowsAuthenticati
   System.Web.Security/WindowsAuthenticationModule.cs
   System.Web/ServerVariablesCollection.cs
   System.Web.SessionState/HttpSessionState.cs
---System.Web.SessionState/IHttpSessionState.cs
   System.Web.SessionState/IReadOnlySessionState.cs
   System.Web.SessionState/IRequiresSessionState.cs
   System.Web.SessionState/ISessionHandler.cs
---System.Web.SessionState/ISessionIDManager.cs
---System.Web.SessionState/ISessionStateItemCollection.cs
   System.Web.SessionState/IStateRuntime.cs
   System.Web.SessionState/RemoteStateServer.cs
   System.Web.SessionState/SessionConfig.cs
@@@@ -415,15 -415,15 -415,15 +412,30 @@@@ System.Web.SessionState/SessionDictiona
   System.Web.SessionState/SessionId.cs
   System.Web.SessionState/SessionInProcHandler.cs
   System.Web.SessionState/SessionSQLServerHandler.cs
---System.Web.SessionState/SessionStateActions.cs
---System.Web.SessionState/SessionStateItemExpireCallback.cs
   System.Web.SessionState/SessionStateMode.cs
   System.Web.SessionState/SessionStateModule.cs
   System.Web.SessionState/SessionStateSectionHandler.cs
   System.Web.SessionState/SessionStateServerHandler.cs
---System.Web.SessionState/SessionStateStoreData.cs
   System.Web.SessionState/StateRuntime.cs
   System.Web.SessionState/StateServerItem.cs
+++System.Web.SessionState_2.0/HttpSessionStateContainer.cs
+++System.Web.SessionState_2.0/HttpSessionState.cs
+++System.Web.SessionState_2.0/IHttpSessionState.cs
+++System.Web.SessionState_2.0/ISessionIDManager.cs
+++System.Web.SessionState_2.0/ISessionStateItemCollection.cs
+++System.Web.SessionState_2.0/RemoteStateServer.cs
+++System.Web.SessionState_2.0/SessionIDManager.cs
+++System.Web.SessionState_2.0/SessionInProcHandler.cs
+++System.Web.SessionState_2.0/SessionSQLServerHandler.cs
+++System.Web.SessionState_2.0/SessionStateActions.cs
+++System.Web.SessionState_2.0/SessionStateItemCollection.cs
+++System.Web.SessionState_2.0/SessionStateItemExpireCallback.cs
+++System.Web.SessionState_2.0/SessionStateModule.cs
+++System.Web.SessionState_2.0/SessionStateServerHandler.cs
+++System.Web.SessionState_2.0/SessionStateStoreData.cs
+++System.Web.SessionState_2.0/SessionStateStoreProviderBase.cs
+++System.Web.SessionState_2.0/SessionStateUtility.cs
+++System.Web.SessionState_2.0/StateServerItem.cs
   System.Web/SiteMap.cs
   System.Web/SiteMapNodeCollection.cs
   System.Web/SiteMapNode.cs
index d86c79b04e3861858c3744f16e01425ec4d918b3,d86c79b04e3861858c3744f16e01425ec4d918b3,d86c79b04e3861858c3744f16e01425ec4d918b3..4fd011902838812f2c0222a5054e69b3a64f81e1
@@@@ -298,6 -298,6 -298,6 +298,11 @@@@ namespace System.Web 
                }
   
                internal static void InvokeSessionEnd (object state)
+++             {
+++                     InvokeSessionEnd (state, null, EventArgs.Empty);
+++             }
+++             
+++             internal static void InvokeSessionEnd (object state, object source, EventArgs e)
                {
                        HttpApplicationFactory factory = theFactory;
                        MethodInfo method = null;
   
                        app.SetSession ((HttpSessionState) state);
                        try {
---                             method.Invoke (app, new object [] {app, EventArgs.Empty});
+++                             method.Invoke (app, new object [] {(source == null ? app : source), e});
                        } catch (Exception) {
                                // Ignore
                        }