Example #1
0
        public static GetRecentQuestionsConsoleAdapter Create(JsonStore store, IWebRequester web, SingleStore <Action <string[]> > currentQuestion)
        {
            var getter = new GetRecentQuestionsConsoleAdapter(store, web, currentQuestion);

            getter.Initialize();
            return(getter);
        }
Example #2
0
        public Task <IConnectionState> Run(Action <ServerSentEvent> donothing, CancellationToken cancelToken)
        {
            IWebRequester requester = _webRequesterFactory.Create();
            var           taskResp  = requester.Get(_url, _tokenService, _headers);

            return(taskResp.ContinueWith <IConnectionState>(tsk =>
            {
                if (tsk.Status == TaskStatus.RanToCompletion && !cancelToken.IsCancellationRequested)
                {
                    IServerResponse response = tsk.Result;
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        return new ConnectedState(response, _webRequesterFactory, _headers, _tokenService, _logger);
                    }
                    else
                    {
                        _logger.LogInformation("Failed to connect to: " + _url.ToString() + response ?? (" Http statuscode: " + response.StatusCode));
                    }
                }
                else
                {
                    _logger.LogDebug("Task Status {@Status}: {Reason}", tsk.Status, ExceptionDetails.InnermostMessage(tsk.Exception));
                }

                return new DisconnectedState(_url, _webRequesterFactory, _headers, _tokenService, _logger);
            }));
        }
Example #3
0
 public ViewModel(IWebRequester requester)
 {
     if (requester == null)
         throw new ArgumentNullException(nameof(requester));
     this.requester = requester;
     SendRequestCommand = new SimpleCommand(SendRequestCommandExecute);
 }
Example #4
0
 public GetRecentQuestionsConsoleAdapter(JsonStore store, IWebRequester web, SingleStore <Action <string[]> > currentQuestion)
 {
     _store           = store;
     _throttle        = new ThrottleChecker(_store);
     _web             = web;
     _currentQuestion = currentQuestion;
 }
Example #5
0
 public RecentQuestionsGetter(JsonStore store, IWebRequester web, string[] tags, string site = "stackoverflow", int pagesize = 30)
 {
     _store   = store;
     _web     = web;
     Tags     = tags;
     Site     = site;
     Pagesize = pagesize;
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the VerifyService class with a supplied credential and uri and
 /// a web requester. In general you do not need to use this constructor unless you want to intercept
 /// the web requests for logging/debugging/testing purposes.
 /// </summary>
 /// <param name="configuration">The configuration information for the service.</param>
 /// <param name="webRequester">The web requester to use.</param>
 /// <param name="responseParser">The parse to use for parsing JSON responses.</param>
 public VerifyService(
     TeleSignServiceConfiguration configuration,
     IWebRequester webRequester,
     IVerifyResponseParser responseParser)
     : base(configuration, webRequester)
 {
     this.parser = responseParser;
 }
 protected virtual void Dispose(bool disposing)
 {
     if (webRequester != null)
     {
         webRequester.Dispose();
         webRequester = null;
     }
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the VerifyService class with a supplied credential and uri and
 /// a web requester. In general you do not need to use this constructor unless you want to intercept
 /// the web requests for logging/debugging/testing purposes.
 /// </summary>
 /// <param name="configuration">The configuration information for the service.</param>
 /// <param name="webRequester">The web requester to use.</param>
 /// <param name="responseParser">The parse to use for parsing JSON responses.</param>
 public VerifyService(
             TeleSignServiceConfiguration configuration, 
             IWebRequester webRequester,
             IVerifyResponseParser responseParser)
     : base(configuration, webRequester)
 {
     this.parser = responseParser;
 }
Example #9
0
        public async Task <bool> TestQuestionsHaveValidLinks(IWebRequester web)
        {
            var result = true;
            var tests  = QuestionsWithEitherJavaOrCSharpSince2017.Take(5).Select(async(q) => (await web.Request(q.Link)).StatusCode == HttpStatusCode.OK);

            result = (await Task.WhenAll(tests)).All((t) => t);
            return(result);
        }
Example #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HBaseClient"/> class.
        /// </summary>
        /// <param name="factory"></param>
        /// <param name="options">The global request options.</param>
        public HBaseClient(IHttpMessageHandlerFactory factory, [NotNull] RequestOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _requester = new WebRequester(factory.CreateHandler, options);
        }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the VerifyService class with a supplied credential and uri and
 /// a web requester. In general you do not need to use this constructor unless you want to intercept
 /// the web requests for logging/debugging/testing purposes.
 /// </summary>
 /// <param name="configuration">The configuration information for the service.</param>
 /// <param name="webRequester">The web requester to use.</param>
 /// <param name="responseParser">The parse to use for parsing JSON responses.</param>
 public VerifyService(
             TeleSignServiceConfiguration configuration, 
             IWebRequester webRequester,
             IVerifyResponseParser responseParser, string senderID = null)
     : base(configuration, webRequester)
 {
     this.parser = responseParser;
     this.senderID = senderID;
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the PhoneIdService class with
 /// a configuration and a custom web requester and response parser.
 /// You generally don't need to use this constructor.
 /// </summary>
 /// <param name="configuration">The configuration information for the service.</param>
 /// <param name="webRequester">The web requester to use.</param>
 /// <param name="responseParser">The response parser to use.</param>
 public PhoneIdService(
     TeleSignServiceConfiguration configuration,
     IWebRequester webRequester,
     IPhoneIdResponseParser responseParser)
     : base(configuration, webRequester)
 {
     // TODO: null check and possible ifdef for JSON.Net
     this.responseParser = responseParser;
 }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the PhoneIdService class with
 /// a configuration and a custom web requester and response parser. 
 /// You generally don't need to use this constructor.
 /// </summary>
 /// <param name="configuration">The configuration information for the service.</param>
 /// <param name="webRequester">The web requester to use.</param>
 /// <param name="responseParser">The response parser to use.</param>
 public PhoneIdService(
             TeleSignServiceConfiguration configuration, 
             IWebRequester webRequester,
             IPhoneIdResponseParser responseParser)
     : base(configuration, webRequester)
 {
     // TODO: null check and possible ifdef for JSON.Net
     this.responseParser = responseParser;
 }
        private RawPhoneIdService CreateService(IWebRequester webRequester = null)
        {
            if (webRequester == null)
            {
                webRequester = new FakeWebRequester();
            }

            return(new RawPhoneIdService(this.GetConfiguration(), webRequester));
        }
        private RawVerifyService CreateService(IWebRequester webRequester = null)
        {
            if (webRequester == null)
            {
                webRequester = new FakeWebRequester();
            }

            return new RawVerifyService(this.GetConfiguration(), webRequester);
        }
Example #16
0
 public EnigmaCommand([NotNull] IFactory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException("factory");
     }
     Factory   = factory;
     Log       = Factory.Log();
     Requester = Factory.WebRequester();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PhoenixClient"/> class. If the client is used
 /// within a VNET or on an on-premise cluster, no cluster credentials required. Pass null in 
 /// this case.
 /// </summary>
 public PhoenixClient(ClusterCredentials credentials)
 {
     if (credentials != null) // gateway mode
     {
         _requester = new GatewayWebRequester(credentials);
     }
     else // vnet mode
     {
         _requester = new VNetWebRequester();
     }
 }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PhoenixClient"/> class. If the client is used
 /// within a VNET or on an on-premise cluster, no cluster credentials required. Pass null in
 /// this case.
 /// </summary>
 public PhoenixClient(ClusterCredentials credentials)
 {
     if (credentials != null) // gateway mode
     {
         _requester = new GatewayWebRequester(credentials);
     }
     else // vnet mode
     {
         _requester = new VNetWebRequester();
     }
 }
 public HBaseClient(ClusterCredentials credentials, RequestOptions globalRequestOptions = null, ILoadBalancer loadBalancer = null)
 {
     _globalRequestOptions = globalRequestOptions ?? RequestOptions.GetDefaultOptions();
     _globalRequestOptions.Validate();
     if (credentials != null) // gateway mode
     {
         _requester = new GatewayWebRequester(credentials);
     }
     else // vnet mode
     {
         _requester = new VNetWebRequester(loadBalancer);
     }
 }
Example #20
0
        public HBaseClient([NotNull] RequestOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _handler = new HttpClientHandler {
                AllowAutoRedirect = false
            };

            _requester = new WebRequester(_ => _handler, options);
        }
Example #21
0
        public YandexTranslator(string apiKey, IWebRequester <XmlDocument> requester)
        {
            if (string.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentNullException("apiKey");
            }
            if (requester == null)
            {
                throw new ArgumentNullException("requester");
            }

            _apiKey    = apiKey;
            _requester = requester;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HBaseClient"/> class.
        /// </summary>
        /// <param name="credentials">The credentials.</param>
        /// <param name="retryPolicyFactory">The retry policy factory.</param>
        public HBaseClient(ClusterCredentials credentials, IRetryPolicyFactory retryPolicyFactory, ILoadBalancer loadBalancer = null)
        {
            retryPolicyFactory.ArgumentNotNull("retryPolicyFactory");

            if (credentials != null)
            {
                _requester = new WebRequesterSecure(credentials);
            }
            else
            {
                _requester    = new WebRequesterBasic();
                _loadBalancer = loadBalancer;
            }

            _retryPolicyFactory = retryPolicyFactory;
        }
        private ModelObjectsBuilder GetModelObjectsBuilder()
        {
            var isTorProxy = (bool)cbTorProxy.IsChecked;
            var isHeadless = (bool)cbHeadlessBrowser.IsChecked;

            if (webRequester == null)
            {
                webRequester = new SeleniumWebRequester(isTorProxy, isHeadless);
            }

            var objectBuilder = new ModelObjectsBuilder(
                new SeasonInfoDownloader(webRequester),
                new TvSeriesInfoDownloader(webRequester));

            return(objectBuilder);
        }
Example #24
0
        /// <summary>
        /// Initializes a new instance of the TeleSignService class with the supplied
        /// configuration and webrequester.
        /// </summary>
        /// <param name="configuration">The configuration information for the service. If null will try to read the default configuration file.</param>
        /// <param name="webRequester">The web requester to use to perform web requests. If null will use the default.</param>
        protected TeleSignService(
            TeleSignServiceConfiguration configuration,
            IWebRequester webRequester)
        {
            this.configuration = (configuration == null)
                        ? TeleSignServiceConfiguration.ReadConfigurationFile()
                        : configuration;

            this.WebRequester = (webRequester == null)
                        ? new WebRequester()
                        : webRequester;

            this.ValidateConfiguration();

            this.authentication = new TeleSignAuthentication(this.configuration.Credential);
        }
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting
 /// unmanaged resources.
 /// </summary>
 /// <remarks>
 /// Since this class is <see langword="sealed"/>, the standard <see
 /// cref="IDisposable.Dispose"/> pattern is not required. Also, <see
 /// cref="GC.SuppressFinalize"/> is not needed.
 /// </remarks>
 public void Dispose()
 {
     if (!_disposed)
     {
         if (_requester != null)
         {
             var disposable = _requester as IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
             _requester = null;
         }
         _disposed = true;
     }
 }
        /// <summary>
        /// Initializes a new instance of the TeleSignService class with the supplied
        /// configuration and webrequester.
        /// </summary>
        /// <param name="configuration">The configuration information for the service. If null will try to read the default configuration file.</param>
        /// <param name="webRequester">The web requester to use to perform web requests. If null will use the default.</param>
        protected TeleSignService(
                    TeleSignServiceConfiguration configuration,
                    IWebRequester webRequester,
                    string accountName = "default")
        {
            this.configuration = (configuration == null)
                        ? TeleSignServiceConfiguration.ReadConfigurationFile(accountName)
                        : configuration;

            this.WebRequester = (webRequester == null)
                        ? new WebRequester()
                        : webRequester;

            this.ValidateConfiguration();

            this.authentication = new TeleSignAuthentication(this.configuration.Credential);
        }
        private PhoneIdService CreateService(
            IWebRequester webRequester            = null,
            IPhoneIdResponseParser responseParser = null)
        {
            if (webRequester == null)
            {
                webRequester = new FakeWebRequester();
            }

            if (responseParser == null)
            {
                responseParser = new FakeResponseParser();
            }

            return(new PhoneIdService(
                       this.GetConfiguration(),
                       webRequester,
                       responseParser));
        }
Example #28
0
        private PhoneIdService CreateService(
                    IWebRequester webRequester = null, 
                    IPhoneIdResponseParser responseParser = null)
        {
            if (webRequester == null)
            {
                webRequester = new FakeWebRequester();
            }

            if (responseParser == null)
            {
                responseParser = new FakeResponseParser();
            }

            return new PhoneIdService(
                        this.GetConfiguration(), 
                        webRequester, 
                        responseParser);
        }
Example #29
0
        private async Task AggregateResult(string testName, IWebRequester web)
        {
            bool result;

            try
            {
                var task = (Task <bool>)GetType().GetMethod("Test" + testName).Invoke(this, new object[] { web });
                await task.ConfigureAwait(false);

                result = task.Result;
            }
            catch
            {
                result = false;
            }
            if (!result)
            {
                TestsFailedString += (TestsPassed ? " ": ", ") + testName;
                TestsPassed        = false;
            }
        }
        public Task <IConnectionState> Run(Action <ServerSentEvent> donothing, CancellationToken cancelToken)
        {
            IWebRequester requester = mWebRequesterFactory.Create();
            var           taskResp  = requester.Get(mUrl);

            return(taskResp.ContinueWith <IConnectionState>(tsk =>
            {
                if (tsk.Status == TaskStatus.RanToCompletion && !cancelToken.IsCancellationRequested)
                {
                    IServerResponse response = tsk.Result;
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        return new ConnectedState(response, mWebRequesterFactory);
                    }
                    else
                    {
                        _logger.Info("Failed to connect to: " + mUrl.ToString() + response ?? (" Http statuscode: " + response.StatusCode));
                    }
                }

                return new DisconnectedState(mUrl, mWebRequesterFactory);
            }));
        }
Example #31
0
 public async Task <bool> TestRecentQuestionGetterGivesQuestionWithAnySpecifiedTags(IWebRequester _)
 {
     return(QuestionsWithEitherJavaOrCSharpSince2017.Any() &&
            QuestionsWithEitherJavaOrCSharpSince2017.All((q) => q.Tags.Contains("c#") || q.Tags.Contains("java")));
 }
 public RateService(TelemetryContext context, IWebRequester webRequester, IMapper mapper) {
     _context = context;
     _mapper = mapper;
     _telemetryService = new TelemetryService(webRequester);
 }
Example #33
0
 public Api(IWebRequester webRequester)
 {
     _webRequester = webRequester;
 }
Example #34
0
 public async Task <bool> TestRecentQuestionGetterGivesRecentQuestions(IWebRequester _)
 {
     return(QuestionsWithEitherJavaOrCSharpSince2017.All((q) => q.CreationDate >= Year2017));
 }
Example #35
0
 /// <summary>
 /// Initializes a new instance of the RawPhoneIdService class with a supplied credential and uri and
 /// a web requester. In general you do not need to use this constructor unless you want to intercept
 /// the web requests for logging/debugging/testing purposes.
 /// </summary>
 /// <param name="configuration">The configuration information for the service.</param>
 /// <param name="webRequester">The web requester to use.</param>
 public RawPhoneIdService(
             TeleSignServiceConfiguration configuration, 
             IWebRequester webRequester)
     : base(configuration, webRequester)
 {
 }
Example #36
0
 public TvSeriesInfoDownloader(IWebRequester webRequester)
 {
     lastInfoRequestAddress = new Uri("http://seasonvar.ru");
     WebRequester           = webRequester;
 }
Example #37
0
 public BrowserEngine(IWebRequester requester)
 {
     _requester = requester;
     _history = new History();
     Cookies = new CookieJar();
 }
 /// <summary>
 /// Initializes a new instance of the RawVerifyService class with a supplied credential and uri and
 /// a web requester. In general you do not need to use this constructor unless you want to intercept
 /// the web requests for logging/debugging/testing purposes.
 /// </summary>
 /// <param name="configuration">The configuration information for the service.</param>
 /// <param name="webRequester">The web requester to use.</param>
 public RawVerifyService(
     TeleSignServiceConfiguration configuration,
     IWebRequester webRequester)
     : base(configuration, webRequester)
 {
 }
Example #39
0
 public async Task <bool> TestRecentQuestionGetterGivesNoDuplicatesAmongPagesOfQuestions(IWebRequester _)
 {
     return(QuestionsWhenUnrestrictedPage2.All((q) => !QuestionsWhenUnrestricted.Contains(q)));
 }
Example #40
0
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
        public async Task <bool> TestRecentQuestionGetterGivesQuestionsWhenNoTagsAreSpecified(IWebRequester _)
        {
            return(QuestionsWhenUnrestricted.Count > 0);
        }
Example #41
0
 public HttpDriver(IWebRequester webRequester)
 {
     _browser = new BrowserEngine(webRequester);
     _navigation = new Navigation(this);
     _manager = new Manage(GetBrowser().Cookies);
 }