public WhichThrowsGraphExceptionThen() { this.facebookClient = new FacebookClient(); var tempState = new WebClientStateContainer { Method = this.httpMethod, RequestUri = new Uri(this.requestUrl), }; this.downloadDataCompletedEventArgs = new DownloadDataCompletedEventArgsWrapper( WebClientFakes.GetFakeWebException(jsonResult), false, tempState, null); }
public ThrowsRestApiErrorThen() { this.facebookClient = new FacebookClient(); var tempState = new WebClientStateContainer { Method = this.httpMethod, RequestUri = new Uri(this.requestUrl), }; this.downloadDataCompletedEventArgs = new DownloadDataCompletedEventArgsWrapper( null, false, tempState, System.Text.Encoding.UTF8.GetBytes(jsonResult)); }
internal void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgsWrapper e) { string json = null; if (e.Error == null && e.Result != null) { json = Encoding.UTF8.GetString(e.Result, 0, e.Result.Length); } HttpMethod method; var args = GetApiEventArgs(e, json, out method); OnGetCompleted(args); }
internal void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgsWrapper e, Func<string, string> processResponseString, Action<object, FacebookApiEventArgs> onDownloadComplete) { Contract.Requires(onDownloadComplete != null); // var userState = (WebClientStateContainer)e.UserState; string json = null; if (e.Error == null && e.Result != null) { json = Encoding.UTF8.GetString(e.Result, 0, e.Result.Length); if (processResponseString != null) { // make the result json json = processResponseString(json); } } HttpMethod method; var args = GetApiEventArgs(e, json, out method); /* * use onDownloadComplete instead, so don't need to do string compare if (userState.RequestUri.AbsolutePath.StartsWith("/oauth/access_token") && GetApplicationAccessTokenCompleted != null) { GetApplicationAccessTokenCompleted(this, args); } */ onDownloadComplete(this, args); }