Beispiel #1
0
        private void LoadItems(string domainName, string fileName)
        {
            long readCount = 0;

            using (FileStream stream = new FileStream(fileName, FileMode.Open))
            {
                using (XmlReader reader = XmlReader.Create(stream))
                {
                    SdbTable table = SdbTable.Create(ServiceId, ServiceSecret, domainName);

                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (reader.LocalName == "Item")
                            {
                                int depth = reader.Depth;

                                if (reader.MoveToAttribute("Name"))
                                {
                                    string itemName = reader.Value;
                                    reader.MoveToElement();

                                    table.Put(itemName, w =>
                                    {
                                        while (reader.Read() && reader.Depth > depth)
                                        {
                                            if (reader.NodeType == XmlNodeType.Element &&
                                                !reader.IsEmptyElement)
                                            {
                                                string name = XmlConvert.DecodeName(reader.LocalName);

                                                if (reader.Read())
                                                {
                                                    string value = reader.ReadContentAsString();

                                                    if (!string.IsNullOrEmpty(value))
                                                    {
                                                        w.AddAttribute(name, value);
                                                    }
                                                }
                                            }
                                        }
                                    });

                                    readCount++;
                                    WriteProgress("Loaded {0} items", readCount);
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine("{0} loaded {1} items {2} bytes", Path.GetFullPath(fileName), readCount, new FileInfo(fileName).Length);
        }
Beispiel #2
0
 protected override ITable CreateTable()
 {
     return(AmazonReliability.Execute(() => new ReliableSdbTable(SdbTable.Create(
                                                                     AmazonTest.ServiceId, AmazonTest.ServiceSecret,
                                                                     GetNextDomainName(), true, SelectLimit))));
 }
Beispiel #3
0
 protected override ITable CreateTable()
 {
     return(AmazonReliability.Execute(() => new ReliableSdbTable(new DelayedTable(SdbTable.Create(
                                                                                      AmazonTest.ServiceId, AmazonTest.ServiceSecret,
                                                                                      GetNextDomainName(), false, SelectLimit), DelayMilliseconds))));
 }
Beispiel #4
0
        private void CreateDomain(string domainName)
        {
            SdbTable.Create(ServiceId, ServiceSecret, domainName);

            Console.WriteLine("Created {0} domain", domainName);
        }