コード例 #1
0
ファイル: TokensBase.cs プロジェクト: acid-chicken/CoreTweet
        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
ファイル: TokensBase.cs プロジェクト: acid-chicken/CoreTweet
        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(url), parameters, cancellationToken)
            .ContinueWith(
                t => InternalUtils.ReadResponse(t, s => CoreBase.Convert <T>(s, jsonPath), cancellationToken),
                cancellationToken
                ).Unwrap().CheckCanceled(cancellationToken));
 }
コード例 #4
0
ファイル: TokensBase.Async.cs プロジェクト: hinaloe/CoreTweet
 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());
 }
コード例 #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 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));
         }
 }
コード例 #7
0
ファイル: TokensBase.Async.cs プロジェクト: hinaloe/CoreTweet
        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));
        }
コード例 #8
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);
         }
 }
コード例 #9
0
ファイル: TokensBase.cs プロジェクト: acid-chicken/CoreTweet
        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();
        }
コード例 #10
0
        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));
        }
コード例 #11
0
ファイル: TokensBase.cs プロジェクト: acid-chicken/CoreTweet
        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));
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        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));
        }
コード例 #14
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));
 }
コード例 #15
0
 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));
 }
コード例 #16
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));
 }
コード例 #17
0
 internal void AccessApiNoResponseImpl(string url, IEnumerable <KeyValuePair <string, object> > parameters)
 {
     this.SendRequestImpl(MethodType.Post, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters).Close();
 }
コード例 #18
0
 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));
 }
コード例 #19
0
ファイル: TokensBase.cs プロジェクト: sergheim/CoreTweet
 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));
 }
コード例 #20
0
ファイル: TokensBase.cs プロジェクト: sergheim/CoreTweet
 internal void AccessApiNoResponse(string url, IDictionary <string, object> parameters)
 {
     this.SendRequest(MethodType.PostNoResponse, InternalUtils.GetUrl(url), parameters);
 }
コード例 #21
0
ファイル: TokensBase.cs プロジェクト: Murtaza-libs/CoreTweet
 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));
 }