Beispiel #1
0
        public void GetCatalog(object userState)
        {
            if (string.IsNullOrEmpty(Uri))
            {
                throw new InvalidOperationException(Resources.Strings.ExceptionUriMustNotBeNull);
            }

            // ensure that catalog requests always end with /databases
            if (!Uri.EndsWith("/databases", StringComparison.OrdinalIgnoreCase) &&
                !Uri.EndsWith("/databases/", StringComparison.OrdinalIgnoreCase))
            {
                if (!Uri.EndsWith("/", StringComparison.Ordinal))
                {
                    Uri += "/";
                }
                Uri += "databases";
            }
            UriBuilder builder = new UriBuilder(Uri);

            builder.Query = Utils.GetQueryParameters(Uri);
            finalUrl      = builder.Uri;

            webClient = WebClientFactory.CreateWebClient();
            webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(this.DownloadStringCompleted);
            webClient.DownloadStringAsync(finalUrl, userState);
        }
Beispiel #2
0
        public void Should_create_webClient_with_correct_userAgent_header()
        {
            const string expected = "test user agent";

            var settingsMock = new Mock <ICrawlerSettingsRepository>();

            settingsMock.Setup(m => m.GetUserAgent()).Returns(expected);

            var factory = new WebClientFactory(settingsMock.Object);

            using (var wc = factory.CreateWebClient())
            {
                Assert.Equal(expected, wc.GetHeader(HttpRequestHeader.UserAgent));
            }
        }
        public void GetTables(object userState)
        {
            if (string.IsNullOrEmpty(Uri))
            {
                throw new InvalidOperationException("Uri must not be null");
            }

            UriBuilder builder = new UriBuilder(Uri);

            builder.Query = Utils.GetQueryParameters(Uri);
            finalUrl      = builder.Uri;

            webClient = WebClientFactory.CreateWebClient();
            webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(this.DownloadStringCompleted);
            webClient.DownloadStringAsync(finalUrl, userState);
        }
        public void GetFeatureServiceDetails(object userState)
        {
            if (string.IsNullOrEmpty(Uri))
            {
                throw new InvalidOperationException(Resources.Strings.ExceptionUriMustNotBeNull);
            }

            UriBuilder builder = new UriBuilder(Uri);

            builder.Query = Utils.GetQueryParameters(Uri);
            finalUrl      = builder.Uri;

            webClient = WebClientFactory.CreateWebClient();
            webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCompleted);
            webClient.DownloadStringAsync(finalUrl, userState);
        }
Beispiel #5
0
 public void Setup()
 {
     _client = WebClientFactory.CreateWebClient();
 }
Beispiel #6
0
        internal async Task <Uri> GetPAyUri(int payId, string subscriptionCode, string email)
        {
            PayServerResponse payServerResponse = JsonConvert.DeserializeObject <PayServerResponse>(await WebClientFactory.CreateWebClient().DownloadStringTaskAsync(string.Format("{0}?payId={1}&subscriptionCode={2}&email={3}", (object)SubscribePayHelper._ApiUrl, (object)payId, (object)subscriptionCode, (object)email)));

            if (!payServerResponse.IsSuccess)
            {
                throw new ArgumentException(payServerResponse.ErrorMessage);
            }
            return(payServerResponse.PayUrl);
        }