當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。