Пример #1
0
        public ITwitterQuery Create(string queryURL, HttpMethod httpMethod)
        {
            var queryURLParameter = new ConstructorNamedParameter("queryURL", queryURL);
            var httpMethodParameter = new ConstructorNamedParameter("httpMethod", httpMethod);

            return _twitterQueryFactory.Create(queryURLParameter, httpMethodParameter);
        }
Пример #2
0
        public ITwitterQuery Create(string queryURL, HttpMethod httpMethod)
        {
            var queryURLParameter = new ConstructorNamedParameter("queryURL", queryURL);
            var httpMethodParameter = new ConstructorNamedParameter("httpMethod", httpMethod);

            var twitterQuery = _twitterQueryFactory.Create(queryURLParameter, httpMethodParameter);

            twitterQuery.Proxy = _tweetinviSettingsAccessor.ProxyURL;
            twitterQuery.Timeout = TimeSpan.FromMilliseconds(_tweetinviSettingsAccessor.WebRequestTimeout);

            return twitterQuery;
        }
        public ITwitterQuery Create(string queryURL, HttpMethod httpMethod, bool withThreadCredentials = false)
        {
            var queryURLParameter = new ConstructorNamedParameter("queryURL", queryURL);
            var httpMethodParameter = new ConstructorNamedParameter("httpMethod", httpMethod);

            var twitterQuery = _twitterQueryFactory.Create(queryURLParameter, httpMethodParameter);

            twitterQuery.Proxy = _tweetinviSettingsAccessor.ProxyURL;
            twitterQuery.Timeout = TimeSpan.FromMilliseconds(_tweetinviSettingsAccessor.WebRequestTimeout);

            if (withThreadCredentials)
            {
                twitterQuery.TwitterCredentials = _credentialsAccessor.CurrentThreadCredentials;
            }

            return twitterQuery;
        }
Пример #4
0
        private string GetJsonResponseFromReader(StreamReader reader, ITwitterQuery twitterQuery)
        {
            var requestTask = reader.ReadLineAsync();
            var resultingTask = TaskEx.WhenAny(requestTask, TaskEx.Delay(STREAM_DISCONNECTED_DELAY)).Result;

            if (resultingTask != requestTask)
            {
                var urlParameter = new ConstructorNamedParameter("url", twitterQuery.QueryURL);
                var twitterTimeoutException = _twitterTimeoutExceptionFactory.Create(urlParameter);
                throw (Exception)twitterTimeoutException;
            }

            var jsonResponse = requestTask.Result;
            return jsonResponse;
        }
Пример #5
0
        private string GetJsonResponseFromReader()
        {
            var requestTask = _currentStreamReader.ReadLineAsync();
            var resultingTask = TaskEx.WhenAny(requestTask, TaskEx.Delay(STREAM_DISCONNECTED_DELAY)).Result;

            if (resultingTask != requestTask)
            {
                var urlParameter = new ConstructorNamedParameter("url", _currentWebRequest.RequestUri.AbsoluteUri);
                var twitterTimeoutException = _twitterTimeoutExceptionFactory.Create(urlParameter);
                throw (Exception)twitterTimeoutException;
            }

            var jsonResponse = requestTask.Result;
            return jsonResponse;
        }