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


C# ApiClient类代码示例

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


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

示例1: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            m_client = new ApiClient("eu");

            QueryBGs();
            QueryData();
        }
开发者ID:XanderMld,项目名称:WoW-Community-Platform-API,代码行数:7,代码来源:MainForm.cs

示例2: Main

        static void Main(string[] args)
        {
            try
            {
                if (!File.Exists(FileName))
                {
                    var newRegistry = ProjectGenerator.GenRegistry(3, 10);
                    newRegistry.Save(FileName);
                }

                var registry = XmlRegistry.Load(FileName);

                // Валидация реестра - урлы в проектах и словах
                XmlRegistry.ValidateRegistry(registry);

                //------

                var apiKey = ConfigurationManager.AppSettings["apikey"];
                if (string.IsNullOrEmpty(apiKey))
                {
                    throw new InvalidOperationException(
                        "Invalid 'apikey' setting in application config.");
                }

                var config = new ClientConfig(apiKey);
                var client = new ApiClient(config);

                var syncClient = new SyncClient(client);

                Console.Write("Project's data loading...");
                syncClient.LoadSyncObjects();

                Console.WriteLine();
                Console.Write("Project's synchronization...");
                syncClient.SyncProjects(registry.Projects);

                Console.WriteLine();
                Console.Write("Groups's synchronization...");
                syncClient.SyncGroups(registry.Projects);

                Console.WriteLine();
                Console.Write("Keywords's synchronization...");
                syncClient.SyncKeywords(registry.Projects);

                Console.WriteLine();
                Console.Write("Synchronization completed, press any key...");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine();
                Console.WriteLine("Error:");
                Console.WriteLine(ex.ToString());
                Console.ResetColor();

                Console.Write("Press any key...");
                Console.ReadKey();
            }
        }
开发者ID:anynomuz,项目名称:topvisor-api,代码行数:60,代码来源:Program.cs

示例3: PluginUpdater

 /// <summary>
 /// Initializes a new instance of the <see cref="PluginUpdater" /> class.
 /// </summary>
 /// <param name="appHost">The app host.</param>
 /// <param name="logger">The logger.</param>
 public PluginUpdater(IApplicationHost appHost, ILogger logger, IApplicationPaths appPaths, ApiClient apiClient)
 {
     _appHost = appHost;
     _logger = logger;
     _appPaths = appPaths;
     _apiClient = apiClient;
 }
开发者ID:EchoDemon,项目名称:MediaBrowser.Theater,代码行数:12,代码来源:PluginUpdater.cs

示例4: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            var client = new ApiClient("eu");
            var item = client.GetItem(70534);
            propertyGrid1.SelectedObject = item;

            var races = client.GetRaces();

            var classes = client.GetClasses();

            var grewards = client.GetGuildRewards();

            var gperks = client.GetGuildPerks();

            var quest = client.GetQuest(25, Locale.ru_RU);

            var recipe = client.GetRecipe(2149, Locale.ru_RU);

            var arena = client.GetArenaLadder("шквал", "2v2");

            // http://eu.battle.net/api/wow/data/guild/perks
            // http://us.battle.net/api/wow/data/character/achievements
            // http://us.battle.net/api/wow/data/guild/achievements
            // http://us.battle.net/api/wow/data/battlegroups/
            // http://us.battle.net/api/wow/pvp/arena/Bloodlust/2v2
            // http://us.battle.net/api/wow/pvp/arena/Bloodlust/2v2?size=5
            // http://us.battle.net/api/wow/data/item/classes
        }
开发者ID:XanderMld,项目名称:WoW-Community-Platform-API,代码行数:28,代码来源:Form1.cs

示例5: GetResult

 public async virtual Task<string> GetResult(ApiClient client) {
     try {
         var url = this.BuildUrl(client.GetUrl(this));
         HttpClient hc = new HttpClient();
         return await hc.GetStringAsync(url);
     } catch (HttpRequestException ex) {
         var bex = ex.GetBaseException();
         var o = new {
             Message = new {
                 messageval = bex.HResult.ToString(),
                 messagestr = bex.Message
             }
         };
         return JsonConvert.SerializeObject(o);
     } catch (WebException ex1) {
         var bex = ex1.GetBaseException();
         var o = new {
             Message = new {
                 messageval = bex.HResult.ToString(),
                 messagestr = bex.Message
             }
         };
         return JsonConvert.SerializeObject(o);
     }
 }
开发者ID:gruan01,项目名称:Discuz.Mobi,代码行数:25,代码来源:MethodBase.cs

示例6: CreateClient

        private static void CreateClient()
        {
            try
            {
                _logger.Info("Creating API Client");
                var device = new Device { DeviceId = SharedUtils.GetDeviceId(), DeviceName = SharedUtils.GetDeviceName() };
                var server = ApplicationSettings.Get<ServerInfo>(Constants.Settings.DefaultServerConnection);
                if (server == null)
                {
                    _logger.Info("No server details found");
                    return;
                }

                var serverAddress = server.LastConnectionMode.HasValue && server.LastConnectionMode.Value == ConnectionMode.Manual ? server.ManualAddress : server.RemoteAddress;
                var client = new ApiClient(MediaBrowserLogger, serverAddress, "Windows Phone 8", device, ApplicationManifest.Current.App.Version, new CryptographyProvider());
                client.SetAuthenticationInfo(server.AccessToken, server.UserId);

                _logger.Info("Client created");
                _apiClient = client;
            }
            catch (Exception ex)
            {
                _logger.FatalException("Error creating ApiClient", ex);
            }
        }
开发者ID:zardaloop,项目名称:Emby.WindowsPhone,代码行数:25,代码来源:ScheduledAgent.cs

示例7: MapObject

        public List<MediaModel> MapObject(List<BaseItemDto> items, ApiClient client)
        {
            MMList = new List<MediaModel>();
              var imageoptions = new ImageOptions
              {
            ImageType = ImageType.Primary,
            Quality = 100
              };

              foreach (BaseItemDto item in items)
              {
            if (item.HasPrimaryImage)
            {
              initializeCatalog();
              MM.LargeCoverArt = client.GetImageUrl(item, imageoptions);
              MM.Title = item.Name;
              MM.Id = item.Path;
              MM.ReleaseYear = item.ProductionYear.ToString();
              MM.Synopsis = item.Overview;
              MM.AverageRating = item.OfficialRating;
              foreach (string g in item.Genres)
              {
            MM.Category.Add(g);
              }
              foreach (BaseItemPerson p in item.People)
              {
            MM.Cast.Add(p.Name);
              }
              MMList.Add(MM);
            }
              }
              return MMList;
        }
开发者ID:hirec,项目名称:SmartHome,代码行数:33,代码来源:MediaObjectMap.cs

示例8: CreateMenuTest

        public static void CreateMenuTest(string weixinID)
        {
            MenuInfo firstButon1 = new MenuInfo();
            firstButon1.type = MenuType.click.ToString();
            firstButon1.name = "下一个笑话";
            firstButon1.key = "V1001_HOT";
            List<MenuInfo> button = new List<MenuInfo>();
            button.Add(firstButon1);
            string menuInfostr = JsonConvert.SerializeObject(new
            {
                button = button

            });

            CreateMenuRequest request = new CreateMenuRequest(menuInfostr, ApiAccessTokenManager.Instance.GetTokenByWeixinID(weixinID));
            ApiClient client = new ApiClient();
            var response = client.Execute(request);
            if (!response.IsError)
            {
                Console.WriteLine(response.ToString());
            }
            else
            {
                Console.WriteLine(response.ErrorCode + ", " + response.ErrorMessage);
            }
        }
开发者ID:cuittzq,项目名称:WeChatService,代码行数:26,代码来源:Program.cs

示例9: GetResult

        public async virtual Task<string> GetResult(ApiClient client) {

            var url = this.BuildUrl(client.GetUrl(this));
            using (var handler = new HttpClientHandler() {
                UseCookies = this.WithCookies,
                AllowAutoRedirect = !this.NeedLoginFirst
            })
            using (HttpClient hc = new HttpClient(handler)) {
                try {
                    var msg = await hc.GetAsync(url);
                    //只有 AllowAutoRedirect 为 false 时,才会捕捉到 Headers.Location
                    if (this.NeedLoginFirst && msg.Headers.Location != null && msg.Headers.Location.Host.Equals("passport.lagou.com")) {
                        this.ErrorType = ErrorTypes.NeedLogin;
                        await this.PrepareLoginCookie(url);
                        return "";
                    } else
                        return await msg.Content.ReadAsStringAsync();

                    //GetStringAsync 会把 302 当作异常抛出
                    //return await hc.GetStringAsync(url);
                } catch (Exception ex) {
                    var bex = ex.GetBaseException();

                    this.ErrorType = bex.HResult.ToString().ParseErrorType();
                    this.Message = bex.Message;
                    return "";
                }
            }
        }
开发者ID:gruan01,项目名称:Lagou.UWP,代码行数:29,代码来源:MethodBase.cs

示例10: loadUsers

 private async Task<UserDto> loadUsers(ApiClient client)
 {            
     //Get Users
     var users = await client.GetUsersAsync();
     var currentUser = users.First();           
     return currentUser;
 }
开发者ID:hirec,项目名称:HireHomeEntertainment,代码行数:7,代码来源:BaseMediaBrowserAPI.cs

示例11: GetApiClient

 private IApiClient GetApiClient()
 {
     var key = new AuthenticationKey(628894, "TQL1KBeSIysqCHZ6slJnWLJM8kQvELjfBqoLD87a1gY9UKj64x2kpPUh2gNsuvgE");
     var mockCacheProvider = new Mock<ICacheProvider>();
     var client = new ApiClient(key, mockCacheProvider.Object);
     return client;
 }
开发者ID:garrym,项目名称:eve-online-fusion,代码行数:7,代码来源:ClientTests.cs

示例12: CreateNumber

        public async void CreateNumber()
        {
            var client = new ApiClient(TestUser, TestPassword);

            var id = await client.CreateNumberAsync("se", new Uri("http://sms.tomv.io/receive"), null, null);
            Assert.IsFalse(string.IsNullOrEmpty(id));
        }
开发者ID:tomv564,项目名称:sms-demo,代码行数:7,代码来源:ApiClientTests.cs

示例13: SendFlashSMS

        public async void SendFlashSMS()
        {
            var client = new ApiClient(TestUser, TestPassword);
            var id = await client.SendSMSAsync("+46702386266", "+46702386266", "The answer is 42", true);
            Assert.IsFalse(string.IsNullOrEmpty(id));

        }
开发者ID:tomv564,项目名称:sms-demo,代码行数:7,代码来源:ApiClientTests.cs

示例14: Configuration

        /// <summary>
        /// Initializes a new instance of the Configuration class with different settings
        /// </summary>
        /// <param name="apiClient">Api client</param>
        /// <param name="defaultHeader">Dictionary of default HTTP header</param>
        /// <param name="username">Username</param>
        /// <param name="password">Password</param>
        /// <param name="accessToken">accessToken</param>
        /// <param name="apiKey">Dictionary of API key</param>
        /// <param name="apiKeyPrefix">Dictionary of API key prefix</param>
        /// <param name="tempFolderPath">Temp folder path</param>
        /// <param name="dateTimeFormat">DateTime format string</param>
        /// <param name="timeout">HTTP connection timeout (in milliseconds)</param>
        /// <param name="userAgent">HTTP user agent</param>
        public Configuration(ApiClient apiClient = null,
                             Dictionary<String, String> defaultHeader = null,
                             string username = null,
                             string password = null,
                             string accessToken = null,
                             Dictionary<String, String> apiKey = null,
                             Dictionary<String, String> apiKeyPrefix = null,
                             string tempFolderPath = null,
                             string dateTimeFormat = null,
                             int timeout = 100000,
                             string userAgent = "Swagger-Codegen/1.0.0/csharp"
                            )
        {
            setApiClientUsingDefault(apiClient);

            Username = username;
            Password = password;
            AccessToken = accessToken;
            UserAgent = userAgent;

            if (defaultHeader != null)
                DefaultHeader = defaultHeader;
            if (apiKey != null)
                ApiKey = apiKey;
            if (apiKeyPrefix != null)
                ApiKeyPrefix = apiKeyPrefix;

            TempFolderPath = tempFolderPath;
            DateTimeFormat = dateTimeFormat;
            Timeout = timeout;
        }
开发者ID:28msec,项目名称:cellstore-csharp,代码行数:45,代码来源:Configuration.cs

示例15: SendWithConfirmationUrl

        public async void SendWithConfirmationUrl()
        {
            var client = new ApiClient(TestUser, TestPassword);

            var id = await client.SendSMSAsync("+46702386266", "+46702386266", "I know you have read this!", false, new Uri("http://sms.tomv.io/confirm"));
            Assert.IsFalse(string.IsNullOrEmpty(id));

        }
开发者ID:tomv564,项目名称:sms-demo,代码行数:8,代码来源:ApiClientTests.cs


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