当前位置: 首页>>代码示例>>C#>>正文


C# IWebClient类代码示例

本文整理汇总了C#中IWebClient的典型用法代码示例。如果您正苦于以下问题:C# IWebClient类的具体用法?C# IWebClient怎么用?C# IWebClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IWebClient类属于命名空间,在下文中一共展示了IWebClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TwitterAccountProvider

        public TwitterAccountProvider(IWebClient webClient, UserCredential userCredential)
            :base(webClient)
        {
            if (userCredential.AccessToken == null)
            {
                throw new ArgumentException("TwitterAccountProvider didn't receive AccessToken");
            }
            if (userCredential.AccessTokenSecret == null)
            {
                throw new ArgumentException("TwitterAccountProvider didn't receive AccessTokenSecret");
            }
            if (userCredential.ConsumerKey == null)
            {
                throw new ArgumentException("TwitterAccountProvider didn't receive ConsumerKey");
            }
            if (userCredential.ConsumerSecret == null)
            {
                throw new ArgumentException("TwitterAccountProvider didn't receive ConsumerSecret");
            }

            _accessToken = userCredential.AccessToken;
            _accessTokenSecret = userCredential.AccessTokenSecret;
            _consumerKey = userCredential.ConsumerKey;
            _consumerSecret = userCredential.ConsumerSecret;
        }
开发者ID:IhorSyerkov,项目名称:Azimuth,代码行数:25,代码来源:TwitterAccountProvider.cs

示例2: WebQueueValidator

 public WebQueueValidator(Uri managementUri, IWebTokenProvider tokenProvider, IWebClient webClient)
 {
     _managementUri = managementUri;
     _webClient = webClient;
     _requestFactory = new WebRequestFactory(tokenProvider);
     _uriCreator = new UriCreator(managementUri);
 }
开发者ID:nordvall,项目名称:letterbox,代码行数:7,代码来源:WebQueueValidator.cs

示例3: TryDownloadAsync

        async Task TryDownloadAsync(TransferSpec spec, IWebClient webClient, IAbsoluteFilePath tmpFile) {
            try {
                tmpFile.RemoveReadonlyWhenExists();
                if (!string.IsNullOrWhiteSpace(spec.Uri.UserInfo))
                    webClient.SetAuthInfo(spec.Uri);
                using (webClient.HandleCancellationToken(spec))
                    await webClient.DownloadFileTaskAsync(spec.Uri, tmpFile.ToString()).ConfigureAwait(false);
                VerifyIfNeeded(spec, tmpFile);
                _fileOps.Move(tmpFile, spec.LocalFile);
            } catch (OperationCanceledException e) {
                _fileOps.DeleteIfExists(tmpFile.ToString());
                throw CreateTimeoutException(spec, e);
            } catch (WebException ex) {
                _fileOps.DeleteIfExists(tmpFile.ToString());
                var cancelledEx = ex.InnerException as OperationCanceledException;
                if (cancelledEx != null)
                    throw CreateTimeoutException(spec, cancelledEx);
                if (ex.Status == WebExceptionStatus.RequestCanceled)
                    throw CreateTimeoutException(spec, ex);

                var response = ex.Response as HttpWebResponse;
                if (response == null)
                    throw GenerateDownloadException(spec, ex);

                switch (response.StatusCode) {
                case HttpStatusCode.NotFound:
                    throw new RequestFailedException("Received a 404: NotFound response", ex);
                case HttpStatusCode.Forbidden:
                    throw new RequestFailedException("Received a 403: Forbidden response", ex);
                case HttpStatusCode.Unauthorized:
                    throw new RequestFailedException("Received a 401: Unauthorized response", ex);
                }
                throw GenerateDownloadException(spec, ex);
            }
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:35,代码来源:HttpDownloadProtocol.cs

示例4: Setup

        public void Setup()
        {
            // Query to facebook api
            UserInfoUrl = String.Format(@"https://graph.facebook.com/v2.0/me?access_token={0}&fields=id,first_name,last_name,name,gender,email,birthday,timezone,location,picture.type(large)",
                    AccessToken);

            // Object that we will make Json
            _fbUserData = new FacebookUserData
            {
                Id = "12345",
                FirstName = "Beseda",
                LastName = "Dmitrij",
                Name = "Beseda Dmitrij",
                Gender = "male",
                Email = "[email protected]",
                Birthday = "12/1/1992",
                Timqzone = 2,
                Location = new FacebookUserData.FbLocation() {Id = "1", Name = "Donetsk, Ukraine"},
                Picture = new FacebookUserData.FbPicture()
                {
                    Data = new FacebookUserData.Data
                    {
                        Url = "photo.jpg"
                    }
                },
            };

            _userToJson = JsonConvert.SerializeObject(_fbUserData);

            _webRequest = Substitute.For<IWebClient>();
            _webRequest.GetWebData(UserInfoUrl).Returns(Task.FromResult(_userToJson));
        }
开发者ID:B1naryStudio,项目名称:Azimuth,代码行数:32,代码来源:FacebookAccountProviderTests.cs

示例5: RssPlugin

 public RssPlugin(IBitTorrentEngine torrentEngine, IDataRepository dataRepository, ITimerFactory timerFactory, IWebClient webClient)
 {
     _torrentEngine = torrentEngine;
     _dataRepository = dataRepository;
     _timer = timerFactory.CreateTimer();
     _webClient = webClient;
 }
开发者ID:randacc,项目名称:hdkn,代码行数:7,代码来源:RssPlugin.cs

示例6: Setup

        public void Setup()
        {
            client = Substitute.For<IWebClient>();
            client.Download().Returns(downloadStringResult);

            target = new WebRequestBuilder(client);
        }
开发者ID:ianchute,项目名称:OWiki,代码行数:7,代码来源:WebRequestBuilderTests.cs

示例7: SetUp

 public void SetUp()
 {
     _mockWebClient = MockRepository.GenerateStub<IWebClient>();
     var uri = new Uri("http://valid");
     _uri = uri.ToString();
     _resolver = new HttpProjectXmlResolver(uri) { WebClient = _mockWebClient };
 }
开发者ID:asednev,项目名称:bigvisiblecruise,代码行数:7,代码来源:HttpProjectResolver_Tests.cs

示例8: HtmlForm

        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlForm"/> class.
        /// </summary>
        /// <param name="webClient">Contains the web client to be used to request and submit the form.</param>
        protected HtmlForm( IWebClient webClient )
        {
            WebClient = webClient;

            Attributes = new Dictionary<string, string>( StringComparer.OrdinalIgnoreCase );
            Controls = new List<HtmlFormControl>();
        }
开发者ID:quamotion,项目名称:NScrape,代码行数:11,代码来源:HtmlForm.cs

示例9: CypherClientFactory

 public CypherClientFactory(string baseUri, IWebClient webClient, IWebSerializer serializer, IEntityCache entityCache)
 {
     this._baseUri = baseUri;
     this._webClient = webClient;
     this._serializer = serializer;
     this._entityCache = entityCache;
 }
开发者ID:dgmachado,项目名称:CypherNet,代码行数:7,代码来源:CypherClientFactory.cs

示例10: ApplyConstraint

 public void ApplyConstraint(IWebClient client)
 {
     foreach (var constraint in Constraints)
     {
         constraint.ApplyConstraint(client);
     }
 }
开发者ID:brianhartsock,项目名称:powershell-rackspaceapps,代码行数:7,代码来源:MacroConstraint.cs

示例11: SetUp

        public void SetUp()
        {
            // Query to VK api
            UserInfoUrl = String.Format(
                @"https://api.vk.com/method/users.get?user_id={0}&fields=screen_name,bdate,sex,city,country,photo_max_orig,timezone&v=5.23&access_token={1}",
                UserId,
                AccessToken);

            // Object that we will make Json
            _vkUserData = new VkUserData.VkResponse
            {
                Response = new List<VkUserData>
                {
                    new VkUserData
                    {
                        FirstName = "Beseda",
                        LastName = "Dmitrij",
                        ScreenName = "Beseda Dmitrij",
                        Sex = VkUserData.VkSex.Male,
                        Birthday = "12/1/1992",
                        City = new VkUserData.VkCity {Id = 1, Title = "Donetsk"},
                        Country = new VkUserData.VkCountry {Id = 1, Title = "Ukraine"},
                        Timezone = 2,
                        Photo = "photo.jpg",
                        Email = Email
                    }
                }
            };

            // Make Json
            _userToJson = JsonConvert.SerializeObject(_vkUserData);

            _webRequest = Substitute.For<IWebClient>();
            _webRequest.GetWebData(UserInfoUrl).Returns(Task.FromResult(_userToJson));
        }
开发者ID:IhorSyerkov,项目名称:Azimuth,代码行数:35,代码来源:VKAccountProviderTests.cs

示例12: Setup

        public void Setup()
        {
            client = Substitute.For<IWebClient>();
            client.Headers.Returns(new WebHeaderCollection());

            target = new WebServiceBuilder(client);
        }
开发者ID:ianchute,项目名称:OWiki,代码行数:7,代码来源:WebServiceBuilderTests.cs

示例13: BuildDataFetcher

        public BuildDataFetcher(ViewUrl viewUrl, IConfigSettings configSettings,
								IWebClientFactory webClientFactory)
        {
            _viewUrl = viewUrl;
            _webClientFactory = webClientFactory;
            _webClient = webClientFactory.GetWebClient(configSettings.URL);
            configSettings.AddObserver(this);
        }
开发者ID:PandaWood,项目名称:Cradiator,代码行数:8,代码来源:BuildDataFetcher.cs

示例14: BurritoDayModel

        public BurritoDayModel(IFiber fiber, IWebClient client)
        {
            this.fiber = fiber;
            this.client = client;

            this.fiber.ScheduleOnInterval(this.PollState, 0,
                (long)this.interval.TotalMilliseconds);
        }
开发者ID:ataranto,项目名称:tepeyac,代码行数:8,代码来源:BurritoDayModel.cs

示例15: ServiceBusClient

 public ServiceBusClient(Uri address, IWebTokenProvider tokenManager, IWebClient webClient)
 {
     _address = address;
     _tokenManager = tokenManager;
     _webClient = webClient;
     _webRequestFactory = new WebRequestFactory(tokenManager);
     _serializer = new MessageSerializer();
 }
开发者ID:nordvall,项目名称:letterbox,代码行数:8,代码来源:ServiceBusClient.cs


注:本文中的IWebClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。