public Task Invoke(IDictionary<string, object> environment) { var owinHttpContext = new OwinHttpContext(environment); var routeData = _routes.GetRouteData(owinHttpContext); if (routeData == null) { write404(environment); return Task.Factory.StartNew(() => { }); } new OwinRequestReader().Read(environment); var arguments = new OwinServiceArguments(routeData, environment); var invoker = routeData.RouteHandler.As<FubuRouteHandler>().Invoker; var exceptionHandlingObserver = new ExceptionHandlingObserver(); arguments.Set(typeof(IExceptionHandlingObserver), exceptionHandlingObserver); return Task.Factory.StartNew(() => invoker.Invoke(arguments, routeData.Values)) .ContinueWith(x => { try { x.FinishProcessingTask(exceptionHandlingObserver); } catch (Exception ex) { write500(environment, ex); } }); }
private static void executeRoute(RouteData routeData, Response response, OwinRequestBody request) { var arguments = new OwinServiceArguments(routeData, request, response); var invoker = routeData.RouteHandler.As<FubuRouteHandler>().Invoker; var exceptionHandlingObserver = new ExceptionHandlingObserver(); arguments.Set(typeof(IExceptionHandlingObserver), exceptionHandlingObserver); var task = Task.Factory.StartNew(() => invoker.Invoke(arguments, routeData.Values)); task.ContinueWith(x => { try { x.FinishProcessingTask(exceptionHandlingObserver); } catch (Exception ex) { write500(response, ex); } finally { response.Finish(); } }); }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { var exceptionHandlingObserver = new ExceptionHandlingObserver(); _arguments.Set(typeof(IExceptionHandlingObserver), exceptionHandlingObserver); var task = Task.Factory.StartNew(state => _invoker.Invoke(_arguments, _routeData), exceptionHandlingObserver); task.ContinueWith(x => cb(x)); return task; }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { var exceptionHandlingObserver = new ExceptionHandlingObserver(); _arguments.Set(typeof(IExceptionHandlingObserver), exceptionHandlingObserver); var task = Task.Factory.StartNew(state => _invoker.Invoke(_arguments, _routeData), exceptionHandlingObserver); task.ContinueWith(x => cb(x)); return(task); }