示例#1
0
        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));
                }
        }
示例#2
0
        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));
                }
        }
示例#3
0
 internal Task <T> AccessApiAsyncImpl <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 => CoreBase.Convert <T>(s, jsonPath), cancellationToken),
                cancellationToken
                ).Unwrap());
 }
示例#4
0
 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));
         }
 }
示例#5
0
 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));
         }
 }
示例#6
0
 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 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 <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));
        }
示例#9
0
 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));
 }
示例#10
0
 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));
 }
示例#11
0
 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));
 }
示例#12
0
 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(url), parameters, cancellationToken)
            .ContinueWith(
                t => InternalUtils.ReadResponse(t, s => new ListedResponse <T>(CoreBase.ConvertArray <T>(s, jsonPath)), cancellationToken),
                cancellationToken
                ).Unwrap().CheckCanceled(cancellationToken));
 }