コード例 #1
0
ファイル: FubuOwinHost.cs プロジェクト: kharlamov/fubumvc
        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);
                    }
                });
        }
コード例 #2
0
ファイル: FubuOwinHost.cs プロジェクト: KevM/fubumvc
        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();
                }
            });
        }
コード例 #3
0
 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;
 }
コード例 #4
0
            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);
            }