예제 #1
0
    /* 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;
        }
    }
예제 #2
0
 /// <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)));
 }
예제 #3
0
 /// <summary>
 /// Executes this request.
 /// </summary>
 /// <returns>Service response.</returns>
 GetUserPhotoResponse Execute()
 {
     return(GetUserPhotoRequest.GetResultOrDefault(this.InternalExecute));
 }