/// <summary> /// Ends an asynchronous request to an Internet resource. /// </summary> /// <typeparam name="TElement">Element type of the result.</typeparam> /// <param name="source">Source object of async request.</param> /// <param name="context">The data service context.</param> /// <param name="method">async method name.</param> /// <param name="asyncResult">The asyncResult being ended.</param> /// <returns>The response - result of the request.</returns> internal static IEnumerable <TElement> EndExecute <TElement>(object source, DataServiceContext context, string method, IAsyncResult asyncResult) { QueryResult result = null; try { result = QueryResult.EndExecuteQuery <TElement>(source, method, asyncResult); return(result.ProcessResult <TElement>(result.ServiceRequest.Plan)); } catch (DataServiceQueryException ex) { Exception inEx = ex; while (inEx.InnerException != null) { inEx = inEx.InnerException; } DataServiceClientException serviceEx = inEx as DataServiceClientException; if (context.IgnoreResourceNotFoundException && serviceEx != null && serviceEx.StatusCode == (int)HttpStatusCode.NotFound) { QueryOperationResponse qor = new QueryOperationResponse <TElement>(ex.Response.HeaderCollection, ex.Response.Query, MaterializeAtom.EmptyResults); qor.StatusCode = (int)HttpStatusCode.NotFound; return((IEnumerable <TElement>)qor); } throw; } }
internal static IEnumerable <TElement> EndExecute <TElement>(object source, DataServiceContext context, string method, IAsyncResult asyncResult) { QueryResult result = null; try { result = QueryResult.EndExecuteQuery <TElement>(source, method, asyncResult); return(result.ProcessResult <TElement>(result.ServiceRequest.Plan)); } catch (DataServiceQueryException exception) { Exception innerException = exception; while (innerException.InnerException != null) { innerException = innerException.InnerException; } DataServiceClientException exception3 = innerException as DataServiceClientException; if ((!context.IgnoreResourceNotFoundException || (exception3 == null)) || (exception3.StatusCode != 0x194)) { throw; } QueryOperationResponse response = new QueryOperationResponse <TElement>(new Dictionary <string, string>(exception.Response.Headers), exception.Response.Query, MaterializeAtom.EmptyResults) { StatusCode = 0x194 }; return((IEnumerable <TElement>)response); } }