Esempio n. 1
0
 public void AddRoute(UrlRoute route) {
     route.Bind();
     routes.Add(route);
 }
Esempio n. 2
0
 private async Task<HttpResponse> ProcessRequest(UrlRoute route, HttpListenerContext context) {
     HttpRequest request = new HttpRequest(context.Request);
     HttpResponse response = new HttpResponse();
     Object model = null;
     response.Response = context.Response;
     // BIND MODEL
     if (route.Model != null) {
         var ctors = route.Model.GetConstructors();
         if (ctors.Length < 1) {
             throw new Exception("Could not find parameterless constructor for type " + route.Model.Name);
         }
         model = ctors[0].Invoke(new object[]{});
         route.RequestBinder.Bind(request, ref model);
     }
     // DISPATCH
     if (route.DelegatedController != null) {
         route.DelegatedController(state, request, response, model);
     } else {
         throw new NotImplementedException();
     }
     return response;
 }