public RestfulServiceRequest(IRequestAuthentication authentication, HttpWebRequest httpWebRequest, SerializeDelegate serializeBody, DeserializationDelegate deserializeBody) { _auth = authentication; _request = httpWebRequest; _serializeBody = serializeBody; _deserializeBody = deserializeBody; }
private void Clear() { _auth = null; _request = null; _serializeBody = null; _deserializeBody = null; _bodyBytes = null; }
/// <summary> /// Fetches the request asynchronously and calls one of the appropriate handlers when completed (likely on a separate thread). /// </summary> /// <typeparam name="TResponse">The type to deserialize the response object to</typeparam> /// <param name="handleWebException">Called if a WebException is generated</param> /// <param name="handleGenericException">Called if an Exception is generated</param> /// <param name="completedWithError">Called when either error handler completes</param> /// <param name="handleResponse">Called to handle the successful response with the deserialized response object</param> public void FetchAsync <TResponse>( Action <WebException> handleWebException, Action <Exception> handleGenericException, Action <Exception> completedWithError, Action <TResponse> handleResponse) { if (handleResponse == null) { throw new ArgumentNullException("handleResponse"); } var _handleWebException = handleWebException ?? _defaultHandleWebException; var _handleException = handleGenericException ?? _defaultHandleException; var _completedWithError = completedWithError ?? _defaultDoNothing; try { _bodyBytes = serializeBody(); _auth.Authenticate(_request, _bodyBytes); _auth = null; var _handleResponse = handleResponse; var ast = new AsyncExecutionState <TResponse>(_bodyBytes, _request, _handleWebException, _handleException, _completedWithError, _deserializeBody, _handleResponse); if (_bodyBytes != null) { // Send the body: _request.BeginGetRequestStream(_completeGetRequestStream <TResponse>, ast); } else { _request.BeginGetResponse(_completeGetResponse <TResponse>, ast); } } catch (WebException wex) { _handleWebException(wex); _completedWithError(wex); } catch (Exception ex) { _handleException(ex); _completedWithError(ex); } }
public DocSharingServiceClient(Uri baseUri, IRequestAuthentication authentication) { this.baseUri = baseUri; this.authentication = authentication; }
public CourseServiceClient(Uri baseUri, IRequestAuthentication authentication) { this.baseUri = baseUri; this.authentication = authentication; }
public SitesAPIAsyncClient(Uri baseUri, IRequestAuthentication authentication) { this.baseUri = baseUri; this.authentication = authentication; }
public CalendarServiceAsyncClient(Uri baseUri, IRequestAuthentication authentication) { this.baseUri = baseUri; this.authentication = authentication; }