[asp.net] HttpContext.RewritePath makes sure the passed path is in canonical form.
[mono.git] / mcs / class / System.Web / System.Web / TraceData.cs
index 69c37d3b2840b9e6842b7833480bc13efd128273..8f4c1caf87d1993ee08bfb004bf82e2de9fadff4 100644 (file)
@@ -4,7 +4,7 @@
 // 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;
@@ -62,35 +60,27 @@ namespace System.Web {
                }
        }
 
-       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;
@@ -102,28 +92,17 @@ namespace System.Web {
                }
        }
        
-       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;
@@ -136,19 +115,11 @@ namespace System.Web {
 
                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 ();
@@ -235,18 +206,12 @@ 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);
                }
 
@@ -260,9 +225,7 @@ 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 ()) {
@@ -349,21 +312,16 @@ namespace System.Web {
                        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);
                }
                
@@ -381,19 +339,12 @@ namespace System.Web {
                                                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);
                }
 
@@ -408,11 +359,7 @@ 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
+                                     r.ViewstateSize.ToString (), r.ControlstateSize.ToString ());
                }
                
                void RenderCookies (HtmlTextWriter output)
@@ -423,13 +370,8 @@ namespace System.Web {
                        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);
                }
@@ -451,19 +393,8 @@ namespace System.Web {
                        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);
                }
                
@@ -475,19 +406,8 @@ namespace System.Web {
                        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);
                }