Exemplo n.º 1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListCustomVerificationEmailTemplatesResponse response = new ListCustomVerificationEmailTemplatesResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("CustomVerificationEmailTemplates", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <CustomVerificationEmailTemplateMetadata, CustomVerificationEmailTemplateMetadataUnmarshaller>(CustomVerificationEmailTemplateMetadataUnmarshaller.Instance);
                    response.CustomVerificationEmailTemplates = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, ListCustomVerificationEmailTemplatesResponse response)
        {
            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("CustomVerificationEmailTemplates/member", targetDepth))
                    {
                        var unmarshaller = CustomVerificationEmailTemplateUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.CustomVerificationEmailTemplates.Add(item);
                        continue;
                    }
                    if (context.TestExpression("NextToken", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.NextToken = unmarshaller.Unmarshall(context);
                        continue;
                    }
                }
            }

            return;
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonSimpleEmailServiceConfig config = new AmazonSimpleEmailServiceConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(creds, config);

            ListCustomVerificationEmailTemplatesResponse resp = new ListCustomVerificationEmailTemplatesResponse();

            do
            {
                ListCustomVerificationEmailTemplatesRequest req = new ListCustomVerificationEmailTemplatesRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.ListCustomVerificationEmailTemplates(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.CustomVerificationEmailTemplates)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            ListCustomVerificationEmailTemplatesResponse response = new ListCustomVerificationEmailTemplatesResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("ListCustomVerificationEmailTemplatesResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }