System.Collections.Generic.List.Add(loadBalancerInstance)

Here are the examples of the csharp api System.Collections.Generic.List.Add(loadBalancerInstance) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 View Source File : UcLoadBalancer.cs
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform

private async Task GetLoadBalancerInstanceList(List<string> instanceNoList)
        {
            try
            {
                if (instanceNoList.Count == 0)
                    return;

                string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
                string action = @"/loadbalancer/v2/getLoadBalancerInstanceList";
                List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
                parameters.Add(new KeyValuePair<string, string>("responseFormatType", "json"));

                int i = 0; 
                foreach (var instanceNo in instanceNoList)
                {
                    i++;
                    string loadBalancerInstanceNoListKey = "loadBalancerInstanceNoList." + i;
                    string loadBalancerInstanceNoListValue = instanceNo;
                    parameters.Add(new KeyValuePair<string, string>(loadBalancerInstanceNoListKey, loadBalancerInstanceNoListValue));
                }
                
                SoaCall soaCall = new SoaCall();
                var task = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
                string response = await task;

                JsonSerializerSettings options = new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };

                if (response.Contains("responseError"))
                {
                    hasError hasError = JsonConvert.DeserializeObject<hasError>(response, options);
                    throw new Exception(hasError.responseError.returnMessage);
                }
                else
                {
                    getLoadBalancerInstanceList getLoadBalancerInstanceList = JsonConvert.DeserializeObject<getLoadBalancerInstanceList>(response, options);
                    if (getLoadBalancerInstanceList.getLoadBalancerInstanceListResponse.returnCode.Equals("0"))
                    {
                        loadBalancerInstances.Clear();
                        foreach (var a in getLoadBalancerInstanceList.getLoadBalancerInstanceListResponse.loadBalancerInstanceList)
                        {
                            var item = new loadBalancerInstance
                            {
                                loadBalancerName = a.loadBalancerName,
                                zoneList = a.zoneList,
                                loadBalancerInstanceNo = a.loadBalancerInstanceNo,
                                loadBalancerRuleList = a.loadBalancerRuleList,
                                domainName = a.domainName,
                                loadBalancerInstanceStatus = a.loadBalancerInstanceStatus,
                                loadBalancerInstanceOperation = a.loadBalancerInstanceOperation
                            };
                            loadBalancerInstances.Add(item);
                        }
                        if (getLoadBalancerInstanceList.getLoadBalancerInstanceListResponse.totalRows == 0)
                        {
                            MessageBox.Show("loadbalancer not founds");
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }