// Author(s):
// Jackson Harper (jackson@ximian.com)
//
-// (C) 2004 Novell, Inc (http://www.novell.com)
+// (C) 2004-2009 Novell, Inc (http://www.novell.com)
//
//
using System;
using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
-#if NET_2_0
-using System.Collections.Generic;
-#endif
-
-namespace System.Web {
-
- class InfoTraceData
+namespace System.Web
+{
+ sealed class InfoTraceData
{
public string Category;
public string Message;
}
}
- class ControlTraceData
+ sealed class ControlTraceData
{
public string ControlId;
public Type Type;
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
}
}
- class NameValueTraceData
+ sealed class NameValueTraceData
{
public string Name;
public string Value;
}
}
- internal class TraceData {
-
+ sealed class TraceData
+ {
bool is_first_time;
DateTime first_time;
double prev_time;
-
-#if NET_2_0
Queue <InfoTraceData> info;
Queue <ControlTraceData> control_data;
Queue <NameValueTraceData> cookie_data;
Queue <NameValueTraceData> header_data;
Queue <NameValueTraceData> servervar_data;
Hashtable ctrl_cs;
-#else
- Queue info;
- Queue control_data;
- Queue cookie_data;
- Queue header_data;
- Queue servervar_data;
- //DataTable viewstate_data;
-#endif
-
string request_path;
string session_id;
DateTime request_time;
public TraceData ()
{
-#if NET_2_0
info = new Queue <InfoTraceData> ();
control_data = new Queue <ControlTraceData> ();
cookie_data = new Queue <NameValueTraceData> ();
header_data = new Queue <NameValueTraceData> ();
servervar_data = new Queue <NameValueTraceData> ();
-#else
- info = new Queue ();
- control_data = new Queue ();
- cookie_data = new Queue ();
- header_data = new Queue ();
- servervar_data = new Queue ();
-#endif
/* TODO
viewstate_data = new DataTable ();
return res.Replace (" ", " ");
}
-#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);
}
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 ()) {
table.Rows.Add (SubHeadRow ("Category", "Message", "From First(s)", "From Lasts(s)"));
int pos = 0;
-#if NET_2_0
IEnumerable<InfoTraceData> enumerable = info;
if (TraceMode == TraceMode.SortByCategory) {
List<InfoTraceData> list = new List<InfoTraceData> (info);
- list.Sort (delegate (InfoTraceData x, InfoTraceData y) { return String.Compare (x.Category, y.Category); });
+ list.Sort (delegate (InfoTraceData x, InfoTraceData y) { return String.Compare (x.Category, y.Category, StringComparison.Ordinal); });
enumerable = list;
}
foreach (InfoTraceData i in enumerable)
RenderTraceInfoRow (table, i, pos++);
-#else
- foreach (object o in info)
- RenderTraceInfoRow (table, o as InfoTraceData, pos++);
-#endif
table.RenderControl (output);
}
table.Rows.Add (AltRow ("Control Tree"));
table.Rows.Add (SubHeadRow ("Control Id", "Type",
"Render Size Bytes (including children)",
-#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
foreach (ControlTraceData r in control_data)
RenderControlTraceDataRow (table, r, pos++);
-#else
- foreach (object o in control_data)
- RenderControlTraceDataRow (table, o as ControlTraceData, pos++);
-#endif
table.RenderControl (output);
}
prefix += " ";
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
+ r.ViewstateSize.ToString (), r.ControlstateSize.ToString ());
}
void RenderCookies (HtmlTextWriter output)
table.Rows.Add (SubHeadRow ("Name", "Value", "Size"));
int pos = 0;
-#if NET_2_0
foreach (NameValueTraceData r in cookie_data)
RenderCookieDataRow (table, r, pos++);
-#else
- foreach (object o in cookie_data)
- RenderCookieDataRow (table, o as NameValueTraceData, pos++);
-#endif
table.RenderControl (output);
}
table.Rows.Add (SubHeadRow ("Name", "Value"));
int pos = 0;
-#if NET_2_0
foreach (NameValueTraceData r in header_data)
RenderAltRow (table, pos++, r.Name, r.Value);
-#else
- NameValueTraceData r;
- foreach (object o in header_data) {
- r = o as NameValueTraceData;
- if (r == null)
- continue;
-
- RenderAltRow (table, pos++, r.Name, r.Value);
- }
-#endif
table.RenderControl (output);
}
table.Rows.Add (SubHeadRow ("Name", "Value"));
int pos = 0;
-#if NET_2_0
foreach (NameValueTraceData r in servervar_data)
RenderAltRow (table, pos++, r.Name, r.Value);
-#else
- NameValueTraceData r;
- foreach (object o in servervar_data) {
- r = o as NameValueTraceData;
- if (r == null)
- continue;
-
- RenderAltRow (table, pos++, r.Name, r.Value);
- }
-#endif
table.RenderControl (output);
}
string open, close;
open = close = String.Empty;
if ((bool) i.IsWarning) {
- open = "<font color=\"Red\">";
- close = "</font>";
+ open = "<span style=\"color:red\">";
+ close = "</span>";
}
string t1, t2;
-#if !TARGET_J2EE
if (i.TimeSinceFirst == 0) {
t1 = t2 = String.Empty;
} else
-#endif
{
t1 = i.TimeSinceFirst.ToString ("0.000000");
- t2 = i.TimeSinceLast.ToString ("0.000000");
+ if (i.TimeSinceLast >= 0.1)
+ t2 = "<span style=\"color:red;font-weight:bold\">" + i.TimeSinceLast.ToString ("0.000000") + "</span>";
+ else
+ t2 = i.TimeSinceLast.ToString ("0.000000");
}
RenderAltRow (table, pos, open + (string) i.Category + close,