Cucumber.SimpleDb.Transport.SimpleDbRestService.BatchPutAttributes C# (CSharp) Method

BatchPutAttributes() public method

public BatchPutAttributes ( string domain ) : System.Xml.Linq.XElement
domain string
return System.Xml.Linq.XElement
        public XElement BatchPutAttributes(string domain, params object[] items)
        {
            if (items.Length < 1)
            {
                throw new ArgumentOutOfRangeException ("Must put at least 1 item");
            }
            var values = new NameValueCollection
            {
                { "Action", "BatchPutAttributes" },
                { "DomainName", domain }
            };
            int itemCount = 0;
            try
            {
                foreach (dynamic item in items)
                {
                    if (itemCount >= 25)
                    {
                        throw new SimpleDbException("Batch put is limited to 25 items per request");
                    }
                    values.Add(
                        string.Format("Item.{0}.ItemName", itemCount),
                        item.Name);
                    if (ObjectExtensions.HasMember(item, "Attributes"))
                    {
                        int attributeCount = 0;
                        foreach (dynamic attribute in item.Attributes)
                        {
                            if (ObjectExtensions.HasMember(attribute.Value, "Values"))
                            {
                                for (int i = 0; i < attribute.Value.Values.Count; ++i)
                                {
                                    attributeCount = ParseAttribute(values, itemCount, attributeCount, attribute,
                                        attribute.Value.Values[i].ToString());
                                    attributeCount++;
                                }
                            }
                            else
                            {
                                attributeCount = ParseAttribute(values, itemCount, attributeCount, attribute,
                                    attribute.Value.ToString());
                                attributeCount++;
                            }
                        }
                    }
                    itemCount++;
                }
            }
            catch (Exception ex)
            {
                throw new FormatException("One or more item definitions did not contain the expected properties", ex);
            }
            return InternalExecute(values);
        }

Usage Example

 public void GenerateBatchPutAttributes ()
 {
     var service = new SimpleDbRestService (new PassThroughAwsRestService ());
     var result = service.BatchPutAttributes ("TestDomain1",
         new { Name = "TestItem1", Attributes = new object[] {
                 new { Name = "TestAtt1", Value = "Hello" },
                 new { Name = "TestAtt2", Value = "World" },
                 new { Name = "TestAtt3", Value = new { Value="abc,123", Values = new List<object> {"abc", 123}} }
             }
             },
         new { Name = "TestItem2", Attributes = new object[] {
                 new { Name = "TestAtt4", Value = 123 },
                 new { Name = "TestAtt5", Value = 1.23 },
                 new { Name = "TestAtt6", Value = new { Value="abc,123", Values = new List<object> {"abc", 123}} }
             }
         });
     Assert.AreEqual (result.Elements ().Count (), 20);
     //TODO: more comprehensive check
 }