Beispiel #1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            BatchDeleteAttributesResponse response = new BatchDeleteAttributesResponse();

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

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

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

            return(response);
        }
Beispiel #2
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            BatchDeleteAttributesResponse response = new BatchDeleteAttributesResponse();

            while (context.Read())
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context);
                    }
                }
            }


            return(response);
        }
Beispiel #3
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, BatchDeleteAttributesResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                }
            }

            return;
        }
Beispiel #4
0
        private void btnBatchDeleteAttributes_Click(object sender, RoutedEventArgs e)
        {
            SimpleDBResponseEventHandler <object, ResponseEventArgs> responseHandler = null;

            responseHandler = delegate(object senderOriginal, ResponseEventArgs args)
            {
                ISimpleDBResponse result = args.Response;
                SimpleDB.Client.OnSimpleDBResponse -= responseHandler;
                this.Dispatcher.BeginInvoke(() =>
                {
                    BatchDeleteAttributesResponse response = result as BatchDeleteAttributesResponse;

                    if (null != response)
                    {
                        this.BatchDeleteMessage = "Batch attributes deleted successfully";
                    }
                    else
                    {
                        AmazonSimpleDBException exception = result as AmazonSimpleDBException;
                        if (null != exception)
                        {
                            this.BatchDeleteMessage = "Error: " + exception.Message;
                        }
                    }
                });
            };
            this.BatchDeleteMessage             = "Please wait...";
            SimpleDB.Client.OnSimpleDBResponse += responseHandler;

            BatchDeleteAttributesRequest deleteRequest = new BatchDeleteAttributesRequest()
            {
                DomainName = this.DomainName
            };
            List <DeleteableItem> deleteItem = deleteRequest.Item;

            //List<Amazon.SimpleDB.Model.Attribute> attributeItem1 = new List<Amazon.SimpleDB.Model.Attribute>();
            //List<Amazon.SimpleDB.Model.Attribute> attributeItem2 = new List<Amazon.SimpleDB.Model.Attribute>();

            List <AttributeAndValue> aAndV1 = GetListAttributeAndValueFromString(this.AttributesAndValuesToPut);
            DeleteableItem           item1  = new DeleteableItem {
                ItemName = "OneAttribute"
            };
            DeleteableItem item2 = new DeleteableItem {
                ItemName = "TwoAttribute"
            };

            int index = 0;

            foreach (var item in aAndV1)
            {
                if (index <= aAndV1.Count / 2)
                {
                    item1.Attribute.Add(new Amazon.SimpleDB.Model.Attribute().WithName(item.Attribute).WithValue(item.Value));
                }
                else
                {
                    item2.Attribute.Add(new Amazon.SimpleDB.Model.Attribute().WithName(item.Attribute).WithValue(item.Value));
                }
                index++;
            }

            //attributeItem1.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Category").WithValue("Clothes"));
            //attributeItem1.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Subcategory").WithValue("Sweater"));

            //attributeItem2.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Size").WithValue("Small"));
            //attributeItem2.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Color").WithValue("Siamese"));

            #region Commented
            //Commented because of changes in the Attribute property definition change during resolving FxCop warnings.
            //deleteItem.Add(new DeleteableItem() { Attribute = attributeItem1, ItemName = "OneAttribute" });
            //deleteItem.Add(new DeleteableItem() { Attribute = attributeItem2, ItemName = "TwoAttribute" });

            #endregion Commented
            deleteItem.Add(item1);
            deleteItem.Add(item2);

            SimpleDB.Client.BatchDeleteAttributes(deleteRequest);
        }