Pārlūkot izejas kodu

2007-12-26 Igor Zelmanovich <[email protected]>

* TraceContext.cs:
* TraceData.cs:
make trace considers control state info.

2007-12-26 Igor Zelmanovich <[email protected]>

* Control.cs:
* Page.cs:
make Trace considers control state info.


svn path=/trunk/mcs/; revision=91898

Igor Zelmanovich 18 gadi atpakaļ
vecāks
revīzija
4492d14816

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

@@ -1,3 +1,9 @@
+2007-12-26 Igor Zelmanovich <[email protected]>
+
+	* Control.cs:
+	* Page.cs:
+	make Trace considers control state info.		
+
 2007-12-20 Igor Zelmanovich <[email protected]>
 
 	* Page.cs:	refactoring:

+ 5 - 5
mcs/class/System.Web/System.Web.UI/Control.cs

@@ -1528,8 +1528,8 @@ namespace System.Web.UI
 			if (!EnableViewState)
 				return null;
 
-#if MONO_TRACE
 			TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+#if MONO_TRACE
 			string type_name = null;
 			if (trace != null) {
 				type_name = GetType ().Name;
@@ -1562,21 +1562,21 @@ namespace System.Web.UI
 
 			object thisState = SaveViewState ();
 			if (thisState == null && controlList == null && controlStates == null) {
-#if MONO_TRACE
 				if (trace != null) {
+#if MONO_TRACE
 					trace.Write ("control", "End SaveViewStateRecursive " + _userId + " " + type_name + " saved nothing");
+#endif
 					trace.SaveViewState (this, null);
 				}
-#endif
 				return null;
 			}
 
-#if MONO_TRACE
 			if (trace != null) {
+#if MONO_TRACE
 				trace.Write ("control", "End SaveViewStateRecursive " + _userId + " " + type_name + " saved a Triplet");
+#endif
 				trace.SaveViewState (this, thisState);
 			}
-#endif
 			return new Triplet (thisState, controlList, controlStates);
 		}
 

+ 5 - 0
mcs/class/System.Web/System.Web.UI/Page.cs

@@ -2598,6 +2598,11 @@ public partial class Page : TemplateControl, IHttpHandler
 		for (int n=0; n<state.Length; n++) {
 			state [n] = ((Control) requireStateControls [n]).SaveControlState ();
 			if (state [n] != null) allNull = false;
+			
+			TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+			if (trace != null)
+				trace.SaveControlState ((Control) requireStateControls [n], state [n]);
+
 		}
 		if (allNull) return null;
 		else return state;

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

@@ -1,3 +1,9 @@
+2007-12-26 Igor Zelmanovich <[email protected]>
+	
+	* TraceContext.cs:
+	* TraceData.cs:
+	make trace considers control state info. 		
+
 2007-12-25 Igor Zelmanovich <[email protected]>
 	
 	* HttpApplication.cs: initialize culture each request.

+ 16 - 0
mcs/class/System.Web/System.Web/TraceContext.cs

@@ -45,6 +45,9 @@ namespace System.Web {
 		bool data_saved;
 		bool _haveTrace;
 		Hashtable view_states;
+#if NET_2_0
+		Hashtable control_states;
+#endif
 		Hashtable sizes;
 
 		public TraceContext (HttpContext Context)
@@ -143,7 +146,11 @@ namespace System.Web {
 
 			SetRequestDetails ();
 			if (_Context.Handler is Page)
+#if NET_2_0
+				data.AddControlTree ((Page) _Context.Handler, view_states, control_states, sizes);
+#else
 				data.AddControlTree ((Page) _Context.Handler, view_states, sizes);
+#endif
 
 			AddCookies ();
 			AddHeaders ();
@@ -160,6 +167,15 @@ namespace System.Web {
 			view_states [ctrl] = vs;
 		}
 
+#if NET_2_0
+		internal void SaveControlState (Control ctrl, object vs) {
+			if (control_states == null)
+				control_states = new Hashtable ();
+
+			control_states [ctrl] = vs;
+		}
+#endif
+
 		internal void SaveSize (Control ctrl, int size)
 		{
 			if (sizes == null)

+ 39 - 3
mcs/class/System.Web/System.Web/TraceData.cs

@@ -69,14 +69,24 @@ namespace System.Web {
 		public int RenderSize;
 		public int ViewstateSize;
 		public int Depth;
+#if NET_2_0
+		public int ControlstateSize;
+#endif
 
+#if NET_2_0
+		public ControlTraceData (string controlId, Type type, int renderSize, int viewstateSize, int controlstateSize, int depth)
+#else
 		public ControlTraceData (string controlId, Type type, int renderSize, int viewstateSize, int depth)
+#endif
 		{
 			this.ControlId = controlId;
 			this.Type = type;
 			this.RenderSize = renderSize;
 			this.ViewstateSize = viewstateSize;
 			this.Depth = depth;
+#if NET_2_0
+			this.ControlstateSize = controlstateSize;
+#endif
 		}
 	}
 
@@ -104,6 +114,7 @@ namespace System.Web {
 		private Queue <NameValueTraceData> cookie_data;
 		private Queue <NameValueTraceData> header_data;
 		private Queue <NameValueTraceData> servervar_data;
+		Hashtable ctrl_cs;
 #else
 		private Queue info;
 		private Queue control_data;
@@ -224,11 +235,18 @@ namespace System.Web {
 			return res.Replace (" ", "&nbsp;");
 		}
 		
+#if NET_2_0
+		public void AddControlTree (Page page, Hashtable ctrl_vs, Hashtable ctrl_cs, Hashtable sizes)
+#else
 		public void AddControlTree (Page page, Hashtable ctrl_vs, Hashtable sizes)
+#endif
 		{
 			this.page = page;
 			this.ctrl_vs = ctrl_vs;
 			this.sizes = sizes;
+#if NET_2_0
+			this.ctrl_cs = ctrl_cs;
+#endif
 			AddControl (page, 0);
 		}
 
@@ -242,6 +260,9 @@ namespace System.Web {
 					c.GetType (),
 					GetRenderSize (c),
 					GetViewStateSize (c, (ctrl_vs != null) ? ctrl_vs [c] : null),
+#if NET_2_0
+					GetViewStateSize (c, (ctrl_cs != null) ? ctrl_cs [c] : null),
+#endif
 					control_pos));
 			
 			if (c.HasControls ()) {
@@ -354,8 +375,16 @@ namespace System.Web {
 			table.Rows.Add (AltRow ("Control Tree"));
 			table.Rows.Add (SubHeadRow ("Control Id", "Type",
 						"Render Size Bytes (including children)",
-						String.Format ("View state Size (total: {0} bytes)(excluding children)",
-								page_vs_size)));
+#if TARGET_J2EE
+						"ViewState Size (excluding children)"
+#else
+						String.Format ("ViewState Size (total: {0} bytes)(excluding children)",
+								page_vs_size)
+#endif
+#if NET_2_0
+						,"ControlState Size (excluding children)"
+#endif
+							));
 			
 			int pos = 0;
 #if NET_2_0
@@ -379,7 +408,11 @@ namespace System.Web {
 				prefix += "&nbsp;&nbsp;&nbsp;&nbsp;";
 			RenderAltRow (table, pos, prefix + r.ControlId,
 				      r.Type.ToString (), r.RenderSize.ToString (),
+#if NET_2_0
+					  r.ViewstateSize.ToString (), r.ControlstateSize.ToString ());
+#else
 				      r.ViewstateSize.ToString ());
+#endif
 		}
 		
 		private void RenderCookies (HtmlTextWriter output)
@@ -484,9 +517,12 @@ namespace System.Web {
 			}
 
 			string t1, t2;
+#if !TARGET_J2EE
 			if (i.TimeSinceFirst == 0) {
 				t1 = t2 = String.Empty;
-			} else {
+			} else
+#endif
+			{
 				t1 = i.TimeSinceFirst.ToString ("0.000000");
 				t2 = i.TimeSinceLast.ToString ("0.000000");
 			}