/* private */ static GetUserPhotoResponse GetResultOrDefault(Func <object> serviceResponseFactory) { try { return((GetUserPhotoResponse)serviceResponseFactory()); } catch (ServiceRequestException ex) { // 404 is a valid return code in the case of GetUserPhoto when the photo is // not found, so it is necessary to catch this exception here. WebException webException = ex.InnerException as WebException; if (webException != null) { HttpWebResponse errorResponse = webException.Response as HttpWebResponse; if (errorResponse != null && errorResponse.StatusCode == HttpStatusCode.NotFound) { return(GetUserPhotoRequest.GetNotFoundResponse()); } } throw; } }
/// <summary> /// Ends executing this async request. /// </summary> /// <param name="asyncResult">The async result</param> /// <returns>Service response collection.</returns> GetUserPhotoResponse EndExecute(IAsyncResult asyncResult) { return(GetUserPhotoRequest.GetResultOrDefault(() => this.EndInternalExecute(asyncResult))); }
/// <summary> /// Executes this request. /// </summary> /// <returns>Service response.</returns> GetUserPhotoResponse Execute() { return(GetUserPhotoRequest.GetResultOrDefault(this.InternalExecute)); }