private object ManagedServiceExec(ServiceExecFn serviceExec, IService service, IRequest request, object requestDto) { try { InjectRequestContext(service, request); try { request.Dto = requestDto; requestDto = appHost.OnPreExecuteServiceFilter(service, requestDto, request, request.Response); request.Dto = requestDto; //Executes the service and returns the result var response = serviceExec(request, requestDto); response = appHost.OnPostExecuteServiceFilter(service, response, request, request.Response); return(response); } finally { //Gets disposed by AppHost or ContainerAdapter if set appHost.Release(service); } } catch (TargetInvocationException tex) { //Mono invokes using reflection throw tex.InnerException ?? tex; } }
private object ManagedServiceExec(ServiceExecFn serviceExec, IService service, IRequest request, object requestDto) { try { InjectRequestContext(service, request); object response = null; try { requestDto = appHost.OnPreExecuteServiceFilter(service, requestDto, request, request.Response); if (request.Dto == null) // Don't override existing batched DTO[] { request.Dto = requestDto; } //Executes the service and returns the result response = serviceExec(request, requestDto); response = appHost.OnPostExecuteServiceFilter(service, response, request, request.Response); return(response); } finally { //Gets disposed by AppHost or ContainerAdapter if set var taskResponse = response as Task; if (taskResponse != null) { taskResponse.ContinueWith(task => appHost.Release(service)); } else { appHost.Release(service); } } } catch (TargetInvocationException tex) { //Mono invokes using reflection throw tex.InnerException ?? tex; } }