/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { AllocateHostsResponse response = new AllocateHostsResponse(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth = 2; } while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("hostIdSet/item", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.HostIds.Add(item); continue; } } } return(response); }
public void Run() { try { TencentCloudAPI manager = new TencentCloudAPI(); //使用默认配置 AllocateHostsRequest req1 = new AllocateHostsRequest(); string strParams1 = "{}"; req1 = AllocateHostsRequest.FromJsonString <AllocateHostsRequest>(strParams1); //使用 CvmClient 相关的方法 AllocateHostsResponse resp1 = manager.CvmClient.AllocateHosts(req1).ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine(AbstractModel.ToJsonString(resp1)); //不使用默认配置 Credential cred = new Credential { SecretId = "", SecretKey = "" }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("cbs.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; TencentCloudApiClientParam param = new TencentCloudApiClientParam(); param.ClientProfile = clientProfile; param.Credential = cred; //设置 CbsClient 相关的配置 manager.TencentCloudApiClientParams["CbsClient"] = param; DescribeDisksRequest req = new DescribeDisksRequest(); string strParams = "{}"; req = DescribeDisksRequest.FromJsonString <DescribeDisksRequest>(strParams); //使用 CbsClient 相关的方法 DescribeDisksResponse resp = manager.CbsClient.DescribeDisks(req).ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine(AbstractModel.ToJsonString(resp)); } catch (Exception ex) { Console.WriteLine("ex:" + ex.ToString()); throw ex; } }