internal DictionaryResponse <TKey, TValue> AccessApiDictionaryImpl <TKey, TValue>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, string jsonPath, string urlPrefix, string urlSuffix) { var connectionOptions = this.ConnectionOptions; if (urlPrefix != null || urlSuffix != null) { connectionOptions = this.ConnectionOptions.Clone(); if (urlPrefix != null) { connectionOptions.UrlPrefix = urlPrefix; } if (urlSuffix != null) { connectionOptions.UrlSuffix = urlSuffix; } } using (var response = this.SendRequestImpl(type, InternalUtils.GetUrl(connectionOptions, url), parameters)) using (var sr = new StreamReader(response.GetResponseStream())) { var json = sr.ReadToEnd(); var dic = CoreBase.Convert <Dictionary <TKey, TValue> >(json, jsonPath); return(new DictionaryResponse <TKey, TValue>(dic, InternalUtils.ReadRateLimit(response), json)); } }
internal ListedResponse <T> AccessJsonParameteredApiArrayImpl <T>(string url, IEnumerable <KeyValuePair <string, object> > parameters, string[] jsonMap, string jsonPath, string urlPrefix, string urlSuffix) { var connectionOptions = this.ConnectionOptions; if (urlPrefix != null || urlSuffix != null) { connectionOptions = this.ConnectionOptions.Clone(); if (urlPrefix != null) { connectionOptions.UrlPrefix = urlPrefix; } if (urlSuffix != null) { connectionOptions.UrlSuffix = urlSuffix; } } using (var response = this.SendJsonRequest(InternalUtils.GetUrl(connectionOptions, url), parameters, jsonMap)) using (var sr = new StreamReader(response.GetResponseStream())) { var json = sr.ReadToEnd(); var list = CoreBase.ConvertArray <T>(json, jsonPath); return(new ListedResponse <T>(list, InternalUtils.ReadRateLimit(response), json)); } }
internal Task <T> AccessApiAsyncImpl <T>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken, string jsonPath) { return(this.SendRequestAsyncImpl(type, InternalUtils.GetUrl(url), parameters, cancellationToken) .ContinueWith( t => InternalUtils.ReadResponse(t, s => CoreBase.Convert <T>(s, jsonPath), cancellationToken), cancellationToken ).Unwrap().CheckCanceled(cancellationToken)); }
internal Task <ListedResponse <T> > AccessApiArrayAsyncImpl <T>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken, string jsonPath) { return(this.SendRequestAsyncImpl(type, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters, cancellationToken) .ContinueWith( t => InternalUtils.ReadResponse(t, s => new ListedResponse <T>(CoreBase.ConvertArray <T>(s, jsonPath)), cancellationToken), cancellationToken ).Unwrap()); }
internal DictionaryResponse <TKey, TValue> AccessApiDictionaryImpl <TKey, TValue>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, string jsonPath) { using (var response = this.SendRequestImpl(type, InternalUtils.GetUrl(url), parameters)) using (var sr = new StreamReader(response.GetResponseStream())) { var json = sr.ReadToEnd(); var dic = CoreBase.Convert <Dictionary <TKey, TValue> >(json, jsonPath); return(new DictionaryResponse <TKey, TValue>(dic, InternalUtils.ReadRateLimit(response), json)); } }
internal ListedResponse <T> AccessApiArrayImpl <T>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, string jsonPath) { using (var response = this.SendRequestImpl(type, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters)) using (var sr = new StreamReader(response.GetResponseStream())) { var json = sr.ReadToEnd(); var list = CoreBase.ConvertArray <T>(json, jsonPath); return(new ListedResponse <T>(list, InternalUtils.ReadRateLimit(response), json)); } }
internal Task AccessApiNoResponseAsyncImpl(string url, IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken) { return(this.SendRequestAsyncImpl(MethodType.Post, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters, cancellationToken) .ContinueWith(t => { if (t.IsFaulted) { t.Exception.InnerException.Rethrow(); } t.Result.Dispose(); }, cancellationToken)); }
internal T AccessApiImpl <T>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, string jsonPath) { using (var response = this.SendRequestImpl(type, InternalUtils.GetUrl(url), parameters)) using (var sr = new StreamReader(response.GetResponseStream())) { var json = sr.ReadToEnd(); var result = CoreBase.Convert <T>(json, jsonPath); var twitterResponse = result as ITwitterResponse; if (twitterResponse != null) { twitterResponse.RateLimit = InternalUtils.ReadRateLimit(response); twitterResponse.Json = json; } return(result); } }
internal void AccessApiNoResponseImpl(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, string urlPrefix, string urlSuffix) { var connectionOptions = this.ConnectionOptions; if (urlPrefix != null || urlSuffix != null) { connectionOptions = this.ConnectionOptions.Clone(); if (urlPrefix != null) { connectionOptions.UrlPrefix = urlPrefix; } if (urlSuffix != null) { connectionOptions.UrlSuffix = urlSuffix; } } this.SendRequestImpl(type, InternalUtils.GetUrl(connectionOptions, url), parameters).Close(); }
internal Task AccessApiNoResponseAsyncImpl(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken, string urlPrefix, string urlSuffix) { var connectionOptions = this.ConnectionOptions; if (urlPrefix != null || urlSuffix != null) { connectionOptions = this.ConnectionOptions.Clone(); if (urlPrefix != null) { connectionOptions.UrlPrefix = urlPrefix; } if (urlSuffix != null) { connectionOptions.UrlSuffix = urlSuffix; } } return(this.SendRequestAsyncImpl(type, InternalUtils.GetUrl(connectionOptions, url), parameters, cancellationToken) .Done(res => res.Dispose(), CancellationToken.None)); }
internal T AccessJsonParameteredApiImpl <T>(string url, IEnumerable <KeyValuePair <string, object> > parameters, string[] jsonMap, string jsonPath, string urlPrefix, string urlSuffix) { var connectionOptions = this.ConnectionOptions; if (urlPrefix != null || urlSuffix != null) { connectionOptions = this.ConnectionOptions.Clone(); if (urlPrefix != null) { connectionOptions.UrlPrefix = urlPrefix; } if (urlSuffix != null) { connectionOptions.UrlSuffix = urlSuffix; } } using (var response = this.SendJsonRequest(InternalUtils.GetUrl(connectionOptions, url), parameters, jsonMap)) return(InternalUtils.ReadResponse <T>(response, jsonPath)); }
internal Task <T> AccessJsonParameteredApiAsyncImpl <T>(string url, IEnumerable <KeyValuePair <string, object> > parameters, string[] jsonMap, CancellationToken cancellationToken, string jsonPath, string urlPrefix, string urlSuffix) { var connectionOptions = this.ConnectionOptions; if (urlPrefix != null || urlSuffix != null) { connectionOptions = this.ConnectionOptions.Clone(); if (urlPrefix != null) { connectionOptions.UrlPrefix = urlPrefix; } if (urlSuffix != null) { connectionOptions.UrlSuffix = urlSuffix; } } return(this.SendJsonRequestAsync(InternalUtils.GetUrl(connectionOptions, url), parameters, jsonMap, cancellationToken) .ReadResponse(s => CoreBase.Convert <T>(s, jsonPath), cancellationToken)); }
internal Task <ListedResponse <T> > AccessApiArrayAsyncImpl <T>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken, string jsonPath, string urlPrefix, string urlSuffix) { var connectionOptions = this.ConnectionOptions; if (urlPrefix != null || urlSuffix != null) { connectionOptions = this.ConnectionOptions.Clone(); if (urlPrefix != null) { connectionOptions.UrlPrefix = urlPrefix; } if (urlSuffix != null) { connectionOptions.UrlSuffix = urlSuffix; } } return(this.SendRequestAsyncImpl(type, InternalUtils.GetUrl(connectionOptions, url), parameters, cancellationToken) .ReadResponse(s => new ListedResponse <T>(CoreBase.ConvertArray <T>(s, jsonPath)), cancellationToken)); }
internal Task <DictionaryResponse <TKey, TValue> > AccessApiDictionaryAsyncImpl <TKey, TValue>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken, string jsonPath) { return(this.SendRequestAsyncImpl(type, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters, cancellationToken) .ReadResponse(s => new DictionaryResponse <TKey, TValue>(CoreBase.Convert <Dictionary <TKey, TValue> >(s, jsonPath)), cancellationToken)); }
internal Task AccessApiNoResponseAsyncImpl(string url, IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken) { return(this.SendRequestAsyncImpl(MethodType.Post, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters, cancellationToken) .Done(res => res.Dispose(), CancellationToken.None)); }
internal Task <ListedResponse <T> > AccessJsonParameteredApiArrayAsyncImpl <T>(string url, IEnumerable <KeyValuePair <string, object> > parameters, string[] jsonMap, CancellationToken cancellationToken, string jsonPath) { return(this.SendJsonRequestAsync(InternalUtils.GetUrl(this.ConnectionOptions, url), parameters, jsonMap, cancellationToken) .ReadResponse(s => new ListedResponse <T>(CoreBase.ConvertArray <T>(s, jsonPath)), cancellationToken)); }
internal void AccessApiNoResponseImpl(string url, IEnumerable <KeyValuePair <string, object> > parameters) { this.SendRequestImpl(MethodType.Post, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters).Close(); }
internal T AccessApiImpl <T>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, string jsonPath) { using (var response = this.SendRequestImpl(type, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters)) return(InternalUtils.ReadResponse <T>(response, jsonPath)); }
internal IEnumerable <T> AccessApiArray <T>(MethodType type, string url, IDictionary <string, object> parameters, string jsonPath = "") { using (var s = this.SendRequest(type, InternalUtils.GetUrl(url), parameters)) using (var sr = new StreamReader(s)) return(CoreBase.ConvertArray <T>(this, sr.ReadToEnd(), jsonPath)); }
internal void AccessApiNoResponse(string url, IDictionary <string, object> parameters) { this.SendRequest(MethodType.PostNoResponse, InternalUtils.GetUrl(url), parameters); }
internal T AccessJsonParameteredApiImpl <T>(string url, IEnumerable <KeyValuePair <string, object> > parameters, string[] jsonMap, string jsonPath) { using (var response = this.SendJsonRequest(InternalUtils.GetUrl(this.ConnectionOptions, url), parameters, jsonMap)) return(InternalUtils.ReadResponse <T>(response, jsonPath)); }