예제 #1
0
        /// <summary>
        /// Converts xml into a Address class
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="address"></param>
        internal static void Read(XmlReader reader, Address address)
        {

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(AddressSerializer.Address);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, AddressSerializer.Address))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case AddressSerializer.Country:
                            address.Country = reader.ReadElementContentAsString();
                            break;
                        case AddressSerializer.State:
                            address.State = reader.ReadElementContentAsString();
                            break;
                        case AddressSerializer.City:
                            address.City = reader.ReadElementContentAsString();
                            break;
                        case AddressSerializer.District:
                            address.District = reader.ReadElementContentAsString();
                            break;
                        case AddressSerializer.PostalCode:
                            address.PostalCode = reader.ReadElementContentAsString();
                            break;
                        case AddressSerializer.Street:
                            address.Street = reader.ReadElementContentAsString();
                            break;
                        case AddressSerializer.Number:
                            address.Number = reader.ReadElementContentAsString();
                            break;
                        case AddressSerializer.Complement:
                            address.Complement = reader.ReadElementContentAsString();
                            break;
                        default:
                            XMLParserUtils.SkipElement(reader);
                            break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: Japle/dotnet
 static void Addres2sExample()
 {
     Address address = new Address();
     address.Country = "BRA";
     address.State = "SP";
     address.City = "São Paulo";
     address.District = "Jardim Paulistano";
     address.PostalCode = "01452002";
     address.Street = "Av. Brig. Faria Lima";
     address.Number = "1384";
     address.Complement = "5o. Andar";
 }
예제 #3
0
파일: Program.cs 프로젝트: Japle/dotnet
 static void AddressExample()
 {
     Address address =
         new Address(
             "BRA",
             "SP",
             "São Paulo",
             "Jardim Paulistano",
             "01452002",
             "Av. Brig. Faria Lima",
             "1384",
             "5o. Andar");
 }
예제 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="shipping"></param>
        internal static void Read(XmlReader reader, Shipping shipping)
        {

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(ShippingSerializer.Shipping);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, ShippingSerializer.Shipping))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case ShippingSerializer.ShippingType:
                            shipping.ShippingType = reader.ReadElementContentAsInt();
                            break;
                        case ShippingSerializer.Cost:
                            shipping.Cost = reader.ReadElementContentAsDecimal();
                            break;
                        case AddressSerializer.Address:
                            Address address = new Address();
                            AddressSerializer.Read(reader, address);
                            shipping.Address = address;
                            break;
                        default:
                            XMLParserUtils.SkipElement(reader);
                            break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }