public void BindRootView()
        {
            var rootView = new RootView()
            {
                Contexts = new List <ReflectContext>()
            };

            rootView.Contexts.Add(new ReflectContext()
            {
                Folder = "C:\teste",
                Name   = "Context1"
            }
                                  );
            rootView.Contexts.Add(new ReflectContext()
            {
                Folder = "C:\teste2",
                Name   = "Context2"
            }
                                  );

            ViewBinder.RootFolder = @"..\..\..\Views\ReflectorView.Test\";
            var output = ViewBinder.BindView(rootView);

            var sb = new StringBuilder();

            using (TextReader reader = File.OpenText(ViewBinder.RootFolder + "RootViewOut.txt"))
            {
                sb.Append(reader.ReadToEnd());
            }

            Assert.AreEqual(sb.ToString(), output);
        }
        private void ProcessRequest(object contextobj)
        {
            var context = (HttpListenerContext)contextobj;

            try
            {
                if (context.Request.HttpMethod.Equals("GET"))
                {
                    var msg = context.Request.HttpMethod + " " + context.Request.Url;

                    var runner = Router.Route(context.Request.Url.LocalPath);
                    var view   = runner.Run();

                    var response = ViewBinder.BindView(view);

                    var b = Encoding.UTF8.GetBytes(response);
                    context.Response.ContentLength64 = b.Length;
                    context.Response.OutputStream.Write(b, 0, b.Length);
                    context.Response.StatusCode = 200;
                }
                else
                {
                    throw new Exception(context.Request.HttpMethod + " Not Implemented");
                }
            }
            catch (Exception ex)
            {
                //LOG ERRORS TO Console
                Console.WriteLine("Request error: " + ex);
                var exceptionView = new ExceptionView()
                {
                    Exception = ex
                };

                var response = ViewBinder.BindView(exceptionView);

                byte[] b = Encoding.UTF8.GetBytes(response);
                context.Response.ContentLength64 = b.Length;
                context.Response.OutputStream.Write(b, 0, b.Length);
                context.Response.StatusCode = 500;
            }
            finally
            {
                context.Response.Close();
            }
        }