Example #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)
        {
            SearchProductsResponse response = new SearchProductsResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("NextPageToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextPageToken = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ProductViewAggregations", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, List <ProductViewAggregationValue>, StringUnmarshaller, ListUnmarshaller <ProductViewAggregationValue, ProductViewAggregationValueUnmarshaller> >(StringUnmarshaller.Instance, new ListUnmarshaller <ProductViewAggregationValue, ProductViewAggregationValueUnmarshaller>(ProductViewAggregationValueUnmarshaller.Instance));
                    response.ProductViewAggregations = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ProductViewSummaries", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <ProductViewSummary, ProductViewSummaryUnmarshaller>(ProductViewSummaryUnmarshaller.Instance);
                    response.ProductViewSummaries = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Example #2
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonServiceCatalogConfig config = new AmazonServiceCatalogConfig();

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

            SearchProductsResponse resp = new SearchProductsResponse();

            do
            {
                SearchProductsRequest req = new SearchProductsRequest
                {
                    PageToken = resp.NextPageToken
                    ,
                    PageSize = maxItems
                };

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

                foreach (var obj in resp.ProductViewSummaries)
                {
                    AddObject(obj);
                }

                foreach (var obj in resp.ProductViewAggregations)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextPageToken));
        }