Exemplo n.º 1
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));
                }
        }
Exemplo n.º 2
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));
                }
        }
Exemplo n.º 3
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));
         }
 }
Exemplo n.º 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));
         }
 }
Exemplo n.º 5
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);
         }
 }