Selaa lähdekoodia

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

	* ProfileModule.cs: hook up saving of the request's profile.

	* ProfileBase.cs (Save): call base.Save instead of throwing NIE.


svn path=/trunk/mcs/; revision=53260
Chris Toshok 20 vuotta sitten
vanhempi
sitoutus
354ffbc8d9

+ 6 - 0
mcs/class/System.Web/System.Web.Profile/ChangeLog

@@ -1,3 +1,9 @@
+2005-11-18  Chris Toshok  <[email protected]>
+
+	* ProfileModule.cs: hook up saving of the request's profile.
+
+	* ProfileBase.cs (Save): call base.Save instead of throwing NIE.
+
 2005-11-03  Chris Toshok  <[email protected]>
 
 	* ProfileEventArgs.cs, ProfileProviderCollection.cs,

+ 1 - 1
mcs/class/System.Web/System.Web.Profile/ProfileBase.cs

@@ -74,7 +74,7 @@ namespace System.Web.Profile
 		[MonoTODO]
 		public override void Save ()
 		{
-			throw new NotImplementedException ();
+			base.Save ();
 		}
 
 		[MonoTODO]

+ 21 - 0
mcs/class/System.Web/System.Web.Profile/ProfileModule.cs

@@ -34,6 +34,9 @@ namespace System.Web.Profile
 {
 	public sealed class ProfileModule : IHttpModule
 	{
+		HttpApplication app;
+		ProfileBase profile;
+
 		[MonoTODO]
 		public ProfileModule ()
 		{
@@ -42,11 +45,29 @@ namespace System.Web.Profile
 		[MonoTODO]
 		public void Dispose ()
 		{
+			app.EndRequest -= OnLeave;
 		}
 
 		[MonoTODO]
 		public void Init (HttpApplication app)
 		{
+			this.app = app;
+			app.EndRequest += OnLeave;
+		}
+
+		void OnLeave (object o, EventArgs eventArgs)
+		{
+			if (profile == null)
+				return;
+
+			if (ProfileAutoSaving != null) {
+				ProfileAutoSaveEventArgs args = new ProfileAutoSaveEventArgs (app.Context);
+				ProfileAutoSaving (this, args);
+				if (!args.ContinueWithProfileAutoSave)
+					return;
+			}
+
+			profile.Save();
 		}
 
 		public event ProfileMigrateEventHandler MigrateAnonymous;