using System; using System.Net; using System.Threading; using System.IO; using System.Linq; using MonoTouch.Foundation; namespace MonoCatalog { public class HttpDebug { static HttpListener listener; static Thread handlerThread; static public void Start () { handlerThread = new Thread (HttpServer); handlerThread.Start (); } static byte [] Encode (string str) { return System.Text.Encoding.UTF8.GetBytes (str); } static void HttpServer () { listener = new HttpListener (); listener.Prefixes.Add ("http://*:5000/"); listener.Start (); while (true){ var context = listener.GetContext (); var request = context.Request; var response = context.Response; var tw = new StreamWriter (response.OutputStream); var path = request.Url.AbsolutePath; if (path.StartsWith ("/type/")){ ShowInstancesOf (tw, path.Substring (6)); } else { Summary (tw); } tw.Flush (); response.OutputStream.Close (); } } static void Header (TextWriter c, string title, string script = null) { c.WriteLine ( "
Total surfaced objects: {0}", weakList.Count); var groups = from weak in weakList let nso = weak.Target where nso != null let typeName = nso.GetType ().FullName orderby typeName group nso by typeName into g let gCount = g.ToList ().Count orderby gCount descending select new { Type = g.Key, Instances = g }; var list = groups.ToList (); c.WriteLine ("
Have {0} different types surfaced", list.Count); c.WriteLine ("