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


C# IWebClient.GetWebData方法代码示例

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


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

示例1: 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

示例2: 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

示例3: Setup

        public void Setup()
        {
            _user = new TwitterUser
            {
                Name = "Azimuth Project",
                Location = "Donetsk, Ukraine",
                ScreenName = "AzimuthP",
                ProfileImageUrl = "photo.jpg"
            };

            _webClient = Substitute.For<IWebClient>();
            _webClient.GetWebData(ConsumerKey, ConsumerSecret, AccessToken, AccessSecret).Returns(Task.FromResult(_user));
        }
开发者ID:IhorSyerkov,项目名称:Azimuth,代码行数:13,代码来源:TwitterAccountProviderTests.cs

示例4: Setup

        public void Setup()
        {
            // Parametres for calling GetUSerInfoAsync
            _accessToken = "some access token";
            _userId = "some user id";

            // Query to facebook api
            UserInfoUrl = String.Format(
                @"https://www.googleapis.com/plus/v1/people/{0}?access_token={1}&fields=birthday%2CdisplayName%2Cemails%2Cgender%2Cimage%2Cname(familyName%2CgivenName)%2CplacesLived",
                _userId,
                _accessToken);

            // Object that we will make Json
            const string livePlace = "Donetsk, Ukraine";
            const string liveCity = "Donetsk";
            const string liveCoord = "40,40";
            //const string liveCoord = "40,30";
            _googleUserData = new GoogleUserData
            {
                Name = new GoogleUserData.GoogleName
                {
                    GivenName = "Ivan",
                    FamilyName = "Bakun"
                },
                DisplayName = "Ivan Bakun",
                Gender = "male",
                Emails = new []{new GoogleUserData.Email
                {
                    Type = "account",
                    Value = "[email protected]"
                }},
                Birthday = "26/1/1994",
                PlacesLived = new []{new GoogleUserData.GoogleLocation
                {
                    Primary = true,
                    Value = "Donetsk, Ukraine" 
                } },
                Image = new GoogleUserData.Photo
                {
                    Url = "photo.jpg"
                }
            };
            var coordinates = new
            {
                results = new[]
                {
                    new
                    {
                        geometry = new
                        {
                            location = new
                            {
                                lat = liveCoord.Split(',')[0],
                                lng = liveCoord.Split(',')[1]
                            }
                        }
                    }
                }
            };
            _googleTimeZone = new GoogleUserData.Timezone
            {
                RawOffset = 3600
            };
            _userToJson = JsonConvert.SerializeObject(_googleUserData);
            var locatioToJson = JsonConvert.SerializeObject(coordinates);
            var timezoneToJson = JsonConvert.SerializeObject(_googleTimeZone);
            var userCoordUrl1 = String.Format(
                    @"https://maps.googleapis.com/maps/api/geocode/json?address={0}", livePlace);
            var userCoordUrl2 = String.Format(
                    @"https://maps.googleapis.com/maps/api/geocode/json?address={0}", liveCity);
            var userTimezoneUrl = String.Format(
                        @"https://maps.googleapis.com/maps/api/timezone/json?location={0}&timestamp=1331161200",
                        liveCoord);
            _webRequest = Substitute.For<IWebClient>();
            _webRequest.GetWebData(UserInfoUrl).Returns(x =>
            {
                _userToJson = JsonConvert.SerializeObject(_googleUserData);
                return Task.FromResult(_userToJson);
            });
            _webRequest.GetWebData(userCoordUrl1).Returns(Task.FromResult(locatioToJson));
            _webRequest.GetWebData(userCoordUrl2).Returns(Task.FromResult(locatioToJson));
            _webRequest.GetWebData(userTimezoneUrl).Returns(Task.FromResult(timezoneToJson));
        }
开发者ID:IhorSyerkov,项目名称:Azimuth,代码行数:83,代码来源:GoogleProviderTests.cs


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