Example #1
0
        private TestOrder GetTestOrder(XmlReader reader)
        {
            if (reader == null)
            {
                throw new Exception("reader");
            }

            while (reader.NodeType != XmlNodeType.Element)
            {
                reader.Read();
            }

            if (reader.LocalName != "TestOrder")
            {
                throw new XmlException("Unexpected xml tag " + reader.LocalName);
            }

            reader.Read();

            while (reader.NodeType == XmlNodeType.Whitespace)
            {
                reader.Read();
            }

            TestOrder testOrder = new TestOrder();

            while (reader.LocalName != "TestOrder")
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                    case "ShipName":
                        testOrder.ShipName = reader.ReadElementContentAsString();
                        break;

                    case "ShipAddress":
                        testOrder.ShipAddress = reader.ReadElementContentAsString();
                        break;

                    case "ShipCity":
                        testOrder.ShipCity = reader.ReadElementContentAsString();
                        break;

                    case "ShipPostalCode":
                        testOrder.ShipPostalCode = reader.ReadElementContentAsString();
                        break;

                    case "ShipCountry":
                        testOrder.ShipCountry = reader.ReadElementContentAsString();
                        break;

                    case "PostalCode":
                        testOrder.PostalCode = reader.ReadElementContentAsString();
                        break;

                    case "CustomerID":
                        testOrder.CustomerID = reader.ReadElementContentAsString();
                        break;

                    case "Customers.CompanyName":
                        testOrder.Customers_CompanyName = reader.ReadElementContentAsString();
                        break;

                    case "HomePage":
                        testOrder.Salesperson = reader.ReadElementContentAsString();
                        break;

                    case "Address":
                        testOrder.Address = reader.ReadElementContentAsString();
                        break;

                    case "City":
                        testOrder.City = reader.ReadElementContentAsString();
                        break;

                    case "Country":
                        testOrder.Country = reader.ReadElementContentAsString();
                        break;

                    case "OrderID":
                        testOrder.OrderID = reader.ReadElementContentAsString();
                        break;

                    case "OrderDate":
                        testOrder.OrderDate = reader.ReadElementContentAsString();
                        break;

                    case "RequiredDate":
                        testOrder.RequiredDate = reader.ReadElementContentAsString();
                        break;

                    case "ShippedDate":
                        testOrder.ShippedDate = reader.ReadElementContentAsString();
                        break;

                    case "Shippers.CompanyName":
                        testOrder.Shippers_CompanyName = reader.ReadElementContentAsString();
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                else
                {
                    reader.Read();
                    if ((reader.LocalName == "TestOrders") && reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }
            return(testOrder);
        }