private async Task CreateResultTask(IRestServiceHandler handler, object returnedObject, Type methodReturnType) { var returnedTask = returnedObject as Task; if (returnedTask != null) { await returnedTask; var taskInfo = GetTaskInfo(returnedTask); returnedObject = taskInfo.Item1; methodReturnType = taskInfo.Item2; } if (returnedObject is IAsyncResult) { throw new InvalidOperationException(Resources.Global.InvalidIAsyncResultReturned); } var resultExecutor = new ResultExecutor(); if (methodReturnType == typeof(void)) { resultExecutor.ExecuteNoContent(handler.Context); return; } IResult result = m_resultWrapper.Wrap(handler, returnedObject, methodReturnType); await resultExecutor.Execute(result, handler.Context); }
public sealed override async Task ProcessRequestAsync(HttpContext context) { var serviceContext = Rest.Configuration.ServiceLocator.GetService<IServiceContext>(); m_paramsBuilder = new Lazy<NameValueCollection>(() => PopulateParams(serviceContext), true); IResult result = await ExecuteAsync(serviceContext); if (result == null) { return; } var resultExecutor = new ResultExecutor(); await resultExecutor.Execute(result, serviceContext); }